Avatar of Anony Mous
Anony Mous
 asked on

User and group on files un-tarred

All,

I ssh'd into a server as myself and created a directory called "misc" (for example) in /usr/local/share like this:

sudo mkdir /usr/local/share/misc

Then i cd'd to the /usr/local/share/misc, then i copied a tar file from another directory to the /usr/local/share/misc directory i created.

I then ran sudo tar -xvf mytarfile.tar because the permissions on the tar file were root::root, which extracted all the files in the /usr/local/share/misc.

My question is this, why when i un-tarred the files using sudo, in the directory i created with sudo, was the ownership of every file set to user as "jsmith" (just an example of another user on the system) , and the group was set to "users"?

Why weren't all the files set to root::root or myuserid:myuserid? We are both in sudoers with the same privileges.

Thanks, this one is stumping me.
LinuxLinux Security

Avatar of undefined
Last Comment
woolmilkporc

8/22/2022 - Mon
SOLUTION
woolmilkporc

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
omarfarid

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Anony Mous

ASKER
Running a tar -tvf shows the original ownership as traveller/users. So why would the user "traveller" change to "jsmith" insted of root::root (since i untarred using sudo) or myuserid::myuserid for the same reason? And why would the group stay "users" instead of something else like root or myuserid?

I dont know why it picked the user "jsmith", who is another user on the system as i am, (see original post) and why the group didnt change from "users" to something else. Know the answers to these two questions would help me understand privileges more. I know if could just chown it after wards, but i would still like to know the reasons.

Omarfarid- remember jsmith:users wasnt the original ownership as shown above.
SOLUTION
woolmilkporc

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
omarfarid

Can you till how the tar file was created and is it from the same system / machine? As woolmilkporc said, if it it is taken from some other system, then the user id / group id could be different on that system.
gheist

rsync matches users by name, most other tools by numeric UID
So you need the original passwd/group files and chown accordignly (find . -nouser -o - nogoroup)
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Anony Mous

ASKER
Thanks all for the responses. I am reviewing them now
woolmilkporc

Why grade C? What's wrong with our answers?