What is the easiest way to list all the user:group found in a tarball?Copy just permissions and ownership from one tar file to anotherHow can I list all user names on Solaris 10?Remove group ID from userHow to get rsync to complain if user not foundChange user id and group id ownership of files within a tarball?How to delete user from all secondary groups in FreeBSD?How to replace the user IDs and group IDs with names instead of numbers in “ps”?Tar file with preserved permissions displays user name for user not on current systemIn `/etc/passwd`, can different usernames for the same user ID have different group IDs?list files with specific group and user name
Does cashing a 3% share harm the company itself?
Is a turbocharged piston aircraft the same thing as turboprop?
Installing a sliding patio door...why does the entire frame have to be square, level and plumb?
A new combinatorial property for the character table of a finite group?
How often to check credit card statement
Does the original Game Boy game "Tetris" have a battery memory inside the cartridge?
Cheat at Rock-Paper-Scissors-Lizard-Spock
How do I disable vim from producing backup files?
Would rocket engine exhaust create pockets of gas in space which could hinder further space exploration?
How does an all-female medieval country maintain itself?
Why is Google's quantum supremacy experiment impressive?
How to List the Set of In-links to a Node
Does paying a mortgage early mean you effectively paid a much higher interest rate?
Is it possible to be admitted to CS PhD programs (in US) with scholarship at age 18?
What is Trump's position on the whistle blower allegations? What does he mean by "witch hunt"?
What manages Upper Memory Blocks (UMBs) in MS-DOS?
Why the real and imaginary parts of a complex analytic function are not independent?
How should I push back against ridiculous work time expectations?
Can I be a pilot if I'm emotionally numb?
Potential Postdoc advisor giving exams (assignment) as part of hiring process
Does the House Resolution about the Impeachment Inquiry change anything?
Is this bible in Koine Greek?
"The" for the first time only
Log user out after change of IP address?
What is the easiest way to list all the user:group found in a tarball?
Copy just permissions and ownership from one tar file to anotherHow can I list all user names on Solaris 10?Remove group ID from userHow to get rsync to complain if user not foundChange user id and group id ownership of files within a tarball?How to delete user from all secondary groups in FreeBSD?How to replace the user IDs and group IDs with names instead of numbers in “ps”?Tar file with preserved permissions displays user name for user not on current systemIn `/etc/passwd`, can different usernames for the same user ID have different group IDs?list files with specific group and user name
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I'm installing some of my data from my old server to my new server.
Since I had my old server for ages, I have a huge amount of legacy data with, most certainly, legacy user and group names.
When extracting, tar does its best to match the user and group info by name and uses the identifiers as a fallback or the current user as a last resort.
What I'd like to do is make sure that all the users and groups exist before I do the extraction. That way all the files get the correct ids.
To do that, the best way I can think of is to list all the user and group names found in the tar file. I know I can use the tar tvf backup.tar
command to list all the files, but then I'd have to come up with a way to extract the right two names.
I'm wondering whether there would be a simpler way than using the tv
option. Some tool or command line options that only extracts the user name and group name, the I can use sort -u
to reduce the list to unique entries.
Anyone knows of such a feature?
users tar group
add a comment
|
I'm installing some of my data from my old server to my new server.
Since I had my old server for ages, I have a huge amount of legacy data with, most certainly, legacy user and group names.
When extracting, tar does its best to match the user and group info by name and uses the identifiers as a fallback or the current user as a last resort.
What I'd like to do is make sure that all the users and groups exist before I do the extraction. That way all the files get the correct ids.
To do that, the best way I can think of is to list all the user and group names found in the tar file. I know I can use the tar tvf backup.tar
command to list all the files, but then I'd have to come up with a way to extract the right two names.
I'm wondering whether there would be a simpler way than using the tv
option. Some tool or command line options that only extracts the user name and group name, the I can use sort -u
to reduce the list to unique entries.
Anyone knows of such a feature?
users tar group
add a comment
|
I'm installing some of my data from my old server to my new server.
Since I had my old server for ages, I have a huge amount of legacy data with, most certainly, legacy user and group names.
When extracting, tar does its best to match the user and group info by name and uses the identifiers as a fallback or the current user as a last resort.
What I'd like to do is make sure that all the users and groups exist before I do the extraction. That way all the files get the correct ids.
To do that, the best way I can think of is to list all the user and group names found in the tar file. I know I can use the tar tvf backup.tar
command to list all the files, but then I'd have to come up with a way to extract the right two names.
I'm wondering whether there would be a simpler way than using the tv
option. Some tool or command line options that only extracts the user name and group name, the I can use sort -u
to reduce the list to unique entries.
Anyone knows of such a feature?
users tar group
I'm installing some of my data from my old server to my new server.
Since I had my old server for ages, I have a huge amount of legacy data with, most certainly, legacy user and group names.
When extracting, tar does its best to match the user and group info by name and uses the identifiers as a fallback or the current user as a last resort.
What I'd like to do is make sure that all the users and groups exist before I do the extraction. That way all the files get the correct ids.
To do that, the best way I can think of is to list all the user and group names found in the tar file. I know I can use the tar tvf backup.tar
command to list all the files, but then I'd have to come up with a way to extract the right two names.
I'm wondering whether there would be a simpler way than using the tv
option. Some tool or command line options that only extracts the user name and group name, the I can use sort -u
to reduce the list to unique entries.
Anyone knows of such a feature?
users tar group
users tar group
asked Oct 14 at 19:52
Alexis WilkeAlexis Wilke
1,2637 silver badges19 bronze badges
1,2637 silver badges19 bronze badges
add a comment
|
add a comment
|
2 Answers
2
active
oldest
votes
Interesting question. From a quick look through the man page (searching for "user" and when that didn't turn up results, searching for "owner") the following should do it:
tar xf thetarball.tgz --to-command='sh -c "echo $TAR_UNAME $TAR_GNAME"' | sort | uniq -c
Obviously, change the script according to your needs. You might want $TAR_UID
and $TAR_GID
instead of the names for some use cases.
I recommend also that you read up on the --owner-map
and --group-map
options for tar
; they sound like they could greatly benefit your use case and would be a lot simpler than creating all the users and groups ahead of time.
Well! Look at that! The manual has evolved quite a bit since I last look at it. What I want really are the$TAG_UNAME
and$TAR_GNAME
parameters. The mapping is probably a good idea for some of the entries, but I know for quite a few I want the user on the new system. It's just difficult to make sure I have just the ones I need without a specific list. (Opposed to creating all the users I had on the old system...)
– Alexis Wilke
Oct 14 at 20:06
@AlexisWilke, great, glad I could help! I've edited the suggested command to more precisely suit what you're asking for. (Don't forget to accept the answer if it solved your question.) ;)
– Wildcard
Oct 14 at 20:10
1
He! He! I actually first clicked on the checkmark 14 seconds to soon :-)
– Alexis Wilke
Oct 14 at 20:30
1
I would just usesort -u
instead ofsort | uniq -c
. Uniq count is probably not necessary here.
– Christopher Hunter
Oct 15 at 18:14
An important note about the mapping. It has to be done when you generate the tarball, now when you extract it. So if you already created it, you'll want to look into regenerating it. Also, the$TAG_UNAME
and$TAG_GNAME
need to be checked on the origin server. On the destination those that are missing are going to come out as an empty string!
– Alexis Wilke
Oct 23 at 5:24
add a comment
|
Quickly assembled:
groups:
tar tvf thetarball.tgz | awk 'print $2' | cut -d/ -f2 | sort -u
users:
tar tvf thetarball.tgz | awk 'print $2' | cut -d/ -f1 | sort -u
user/groups pairs:
tar tvf thetarball.tgz | awk 'print $2' | sort -u
3
Note thatsort -u
is probably faster thansort | uniq
.
– Alexis Wilke
Oct 14 at 20:29
@AlexisWilke I upvoted your comment and edited the answer.
– Eduardo Trápani
Oct 14 at 20:36
2
(or just awk:awk '!seen[$2]++ print $2'
)
– muru
Oct 15 at 4:24
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f546769%2fwhat-is-the-easiest-way-to-list-all-the-usergroup-found-in-a-tarball%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Interesting question. From a quick look through the man page (searching for "user" and when that didn't turn up results, searching for "owner") the following should do it:
tar xf thetarball.tgz --to-command='sh -c "echo $TAR_UNAME $TAR_GNAME"' | sort | uniq -c
Obviously, change the script according to your needs. You might want $TAR_UID
and $TAR_GID
instead of the names for some use cases.
I recommend also that you read up on the --owner-map
and --group-map
options for tar
; they sound like they could greatly benefit your use case and would be a lot simpler than creating all the users and groups ahead of time.
Well! Look at that! The manual has evolved quite a bit since I last look at it. What I want really are the$TAG_UNAME
and$TAR_GNAME
parameters. The mapping is probably a good idea for some of the entries, but I know for quite a few I want the user on the new system. It's just difficult to make sure I have just the ones I need without a specific list. (Opposed to creating all the users I had on the old system...)
– Alexis Wilke
Oct 14 at 20:06
@AlexisWilke, great, glad I could help! I've edited the suggested command to more precisely suit what you're asking for. (Don't forget to accept the answer if it solved your question.) ;)
– Wildcard
Oct 14 at 20:10
1
He! He! I actually first clicked on the checkmark 14 seconds to soon :-)
– Alexis Wilke
Oct 14 at 20:30
1
I would just usesort -u
instead ofsort | uniq -c
. Uniq count is probably not necessary here.
– Christopher Hunter
Oct 15 at 18:14
An important note about the mapping. It has to be done when you generate the tarball, now when you extract it. So if you already created it, you'll want to look into regenerating it. Also, the$TAG_UNAME
and$TAG_GNAME
need to be checked on the origin server. On the destination those that are missing are going to come out as an empty string!
– Alexis Wilke
Oct 23 at 5:24
add a comment
|
Interesting question. From a quick look through the man page (searching for "user" and when that didn't turn up results, searching for "owner") the following should do it:
tar xf thetarball.tgz --to-command='sh -c "echo $TAR_UNAME $TAR_GNAME"' | sort | uniq -c
Obviously, change the script according to your needs. You might want $TAR_UID
and $TAR_GID
instead of the names for some use cases.
I recommend also that you read up on the --owner-map
and --group-map
options for tar
; they sound like they could greatly benefit your use case and would be a lot simpler than creating all the users and groups ahead of time.
Well! Look at that! The manual has evolved quite a bit since I last look at it. What I want really are the$TAG_UNAME
and$TAR_GNAME
parameters. The mapping is probably a good idea for some of the entries, but I know for quite a few I want the user on the new system. It's just difficult to make sure I have just the ones I need without a specific list. (Opposed to creating all the users I had on the old system...)
– Alexis Wilke
Oct 14 at 20:06
@AlexisWilke, great, glad I could help! I've edited the suggested command to more precisely suit what you're asking for. (Don't forget to accept the answer if it solved your question.) ;)
– Wildcard
Oct 14 at 20:10
1
He! He! I actually first clicked on the checkmark 14 seconds to soon :-)
– Alexis Wilke
Oct 14 at 20:30
1
I would just usesort -u
instead ofsort | uniq -c
. Uniq count is probably not necessary here.
– Christopher Hunter
Oct 15 at 18:14
An important note about the mapping. It has to be done when you generate the tarball, now when you extract it. So if you already created it, you'll want to look into regenerating it. Also, the$TAG_UNAME
and$TAG_GNAME
need to be checked on the origin server. On the destination those that are missing are going to come out as an empty string!
– Alexis Wilke
Oct 23 at 5:24
add a comment
|
Interesting question. From a quick look through the man page (searching for "user" and when that didn't turn up results, searching for "owner") the following should do it:
tar xf thetarball.tgz --to-command='sh -c "echo $TAR_UNAME $TAR_GNAME"' | sort | uniq -c
Obviously, change the script according to your needs. You might want $TAR_UID
and $TAR_GID
instead of the names for some use cases.
I recommend also that you read up on the --owner-map
and --group-map
options for tar
; they sound like they could greatly benefit your use case and would be a lot simpler than creating all the users and groups ahead of time.
Interesting question. From a quick look through the man page (searching for "user" and when that didn't turn up results, searching for "owner") the following should do it:
tar xf thetarball.tgz --to-command='sh -c "echo $TAR_UNAME $TAR_GNAME"' | sort | uniq -c
Obviously, change the script according to your needs. You might want $TAR_UID
and $TAR_GID
instead of the names for some use cases.
I recommend also that you read up on the --owner-map
and --group-map
options for tar
; they sound like they could greatly benefit your use case and would be a lot simpler than creating all the users and groups ahead of time.
edited Oct 14 at 20:09
answered Oct 14 at 19:59
WildcardWildcard
25.1k11 gold badges74 silver badges188 bronze badges
25.1k11 gold badges74 silver badges188 bronze badges
Well! Look at that! The manual has evolved quite a bit since I last look at it. What I want really are the$TAG_UNAME
and$TAR_GNAME
parameters. The mapping is probably a good idea for some of the entries, but I know for quite a few I want the user on the new system. It's just difficult to make sure I have just the ones I need without a specific list. (Opposed to creating all the users I had on the old system...)
– Alexis Wilke
Oct 14 at 20:06
@AlexisWilke, great, glad I could help! I've edited the suggested command to more precisely suit what you're asking for. (Don't forget to accept the answer if it solved your question.) ;)
– Wildcard
Oct 14 at 20:10
1
He! He! I actually first clicked on the checkmark 14 seconds to soon :-)
– Alexis Wilke
Oct 14 at 20:30
1
I would just usesort -u
instead ofsort | uniq -c
. Uniq count is probably not necessary here.
– Christopher Hunter
Oct 15 at 18:14
An important note about the mapping. It has to be done when you generate the tarball, now when you extract it. So if you already created it, you'll want to look into regenerating it. Also, the$TAG_UNAME
and$TAG_GNAME
need to be checked on the origin server. On the destination those that are missing are going to come out as an empty string!
– Alexis Wilke
Oct 23 at 5:24
add a comment
|
Well! Look at that! The manual has evolved quite a bit since I last look at it. What I want really are the$TAG_UNAME
and$TAR_GNAME
parameters. The mapping is probably a good idea for some of the entries, but I know for quite a few I want the user on the new system. It's just difficult to make sure I have just the ones I need without a specific list. (Opposed to creating all the users I had on the old system...)
– Alexis Wilke
Oct 14 at 20:06
@AlexisWilke, great, glad I could help! I've edited the suggested command to more precisely suit what you're asking for. (Don't forget to accept the answer if it solved your question.) ;)
– Wildcard
Oct 14 at 20:10
1
He! He! I actually first clicked on the checkmark 14 seconds to soon :-)
– Alexis Wilke
Oct 14 at 20:30
1
I would just usesort -u
instead ofsort | uniq -c
. Uniq count is probably not necessary here.
– Christopher Hunter
Oct 15 at 18:14
An important note about the mapping. It has to be done when you generate the tarball, now when you extract it. So if you already created it, you'll want to look into regenerating it. Also, the$TAG_UNAME
and$TAG_GNAME
need to be checked on the origin server. On the destination those that are missing are going to come out as an empty string!
– Alexis Wilke
Oct 23 at 5:24
Well! Look at that! The manual has evolved quite a bit since I last look at it. What I want really are the
$TAG_UNAME
and $TAR_GNAME
parameters. The mapping is probably a good idea for some of the entries, but I know for quite a few I want the user on the new system. It's just difficult to make sure I have just the ones I need without a specific list. (Opposed to creating all the users I had on the old system...)– Alexis Wilke
Oct 14 at 20:06
Well! Look at that! The manual has evolved quite a bit since I last look at it. What I want really are the
$TAG_UNAME
and $TAR_GNAME
parameters. The mapping is probably a good idea for some of the entries, but I know for quite a few I want the user on the new system. It's just difficult to make sure I have just the ones I need without a specific list. (Opposed to creating all the users I had on the old system...)– Alexis Wilke
Oct 14 at 20:06
@AlexisWilke, great, glad I could help! I've edited the suggested command to more precisely suit what you're asking for. (Don't forget to accept the answer if it solved your question.) ;)
– Wildcard
Oct 14 at 20:10
@AlexisWilke, great, glad I could help! I've edited the suggested command to more precisely suit what you're asking for. (Don't forget to accept the answer if it solved your question.) ;)
– Wildcard
Oct 14 at 20:10
1
1
He! He! I actually first clicked on the checkmark 14 seconds to soon :-)
– Alexis Wilke
Oct 14 at 20:30
He! He! I actually first clicked on the checkmark 14 seconds to soon :-)
– Alexis Wilke
Oct 14 at 20:30
1
1
I would just use
sort -u
instead of sort | uniq -c
. Uniq count is probably not necessary here.– Christopher Hunter
Oct 15 at 18:14
I would just use
sort -u
instead of sort | uniq -c
. Uniq count is probably not necessary here.– Christopher Hunter
Oct 15 at 18:14
An important note about the mapping. It has to be done when you generate the tarball, now when you extract it. So if you already created it, you'll want to look into regenerating it. Also, the
$TAG_UNAME
and $TAG_GNAME
need to be checked on the origin server. On the destination those that are missing are going to come out as an empty string!– Alexis Wilke
Oct 23 at 5:24
An important note about the mapping. It has to be done when you generate the tarball, now when you extract it. So if you already created it, you'll want to look into regenerating it. Also, the
$TAG_UNAME
and $TAG_GNAME
need to be checked on the origin server. On the destination those that are missing are going to come out as an empty string!– Alexis Wilke
Oct 23 at 5:24
add a comment
|
Quickly assembled:
groups:
tar tvf thetarball.tgz | awk 'print $2' | cut -d/ -f2 | sort -u
users:
tar tvf thetarball.tgz | awk 'print $2' | cut -d/ -f1 | sort -u
user/groups pairs:
tar tvf thetarball.tgz | awk 'print $2' | sort -u
3
Note thatsort -u
is probably faster thansort | uniq
.
– Alexis Wilke
Oct 14 at 20:29
@AlexisWilke I upvoted your comment and edited the answer.
– Eduardo Trápani
Oct 14 at 20:36
2
(or just awk:awk '!seen[$2]++ print $2'
)
– muru
Oct 15 at 4:24
add a comment
|
Quickly assembled:
groups:
tar tvf thetarball.tgz | awk 'print $2' | cut -d/ -f2 | sort -u
users:
tar tvf thetarball.tgz | awk 'print $2' | cut -d/ -f1 | sort -u
user/groups pairs:
tar tvf thetarball.tgz | awk 'print $2' | sort -u
3
Note thatsort -u
is probably faster thansort | uniq
.
– Alexis Wilke
Oct 14 at 20:29
@AlexisWilke I upvoted your comment and edited the answer.
– Eduardo Trápani
Oct 14 at 20:36
2
(or just awk:awk '!seen[$2]++ print $2'
)
– muru
Oct 15 at 4:24
add a comment
|
Quickly assembled:
groups:
tar tvf thetarball.tgz | awk 'print $2' | cut -d/ -f2 | sort -u
users:
tar tvf thetarball.tgz | awk 'print $2' | cut -d/ -f1 | sort -u
user/groups pairs:
tar tvf thetarball.tgz | awk 'print $2' | sort -u
Quickly assembled:
groups:
tar tvf thetarball.tgz | awk 'print $2' | cut -d/ -f2 | sort -u
users:
tar tvf thetarball.tgz | awk 'print $2' | cut -d/ -f1 | sort -u
user/groups pairs:
tar tvf thetarball.tgz | awk 'print $2' | sort -u
edited Oct 14 at 20:34
answered Oct 14 at 20:10
Eduardo TrápaniEduardo Trápani
7096 bronze badges
7096 bronze badges
3
Note thatsort -u
is probably faster thansort | uniq
.
– Alexis Wilke
Oct 14 at 20:29
@AlexisWilke I upvoted your comment and edited the answer.
– Eduardo Trápani
Oct 14 at 20:36
2
(or just awk:awk '!seen[$2]++ print $2'
)
– muru
Oct 15 at 4:24
add a comment
|
3
Note thatsort -u
is probably faster thansort | uniq
.
– Alexis Wilke
Oct 14 at 20:29
@AlexisWilke I upvoted your comment and edited the answer.
– Eduardo Trápani
Oct 14 at 20:36
2
(or just awk:awk '!seen[$2]++ print $2'
)
– muru
Oct 15 at 4:24
3
3
Note that
sort -u
is probably faster than sort | uniq
.– Alexis Wilke
Oct 14 at 20:29
Note that
sort -u
is probably faster than sort | uniq
.– Alexis Wilke
Oct 14 at 20:29
@AlexisWilke I upvoted your comment and edited the answer.
– Eduardo Trápani
Oct 14 at 20:36
@AlexisWilke I upvoted your comment and edited the answer.
– Eduardo Trápani
Oct 14 at 20:36
2
2
(or just awk:
awk '!seen[$2]++ print $2'
)– muru
Oct 15 at 4:24
(or just awk:
awk '!seen[$2]++ print $2'
)– muru
Oct 15 at 4:24
add a comment
|
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f546769%2fwhat-is-the-easiest-way-to-list-all-the-usergroup-found-in-a-tarball%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown