Start Free Trial
Come for the solution, stay for everything else.
Start Free Trial
Changing ownership when extracting tar
I use the following to extract files:
The problem is that my files were tarred from a place where a owner user was called "olduser" and only that owner had permissions over most of the files.
"olduser" does not exist on my new box, it has been replaced with the owner of "newuser"
How can I extract the files, but at the same time replace all ownership from "olduser" to "newuser" ?
8/22/2022 - Mon
su to "newuser" then do the extract. Only root has the ability to change usernames, so in this case you do *not* want to have an EUID (effective User Id) of root.
ASKER CERTIFIED SOLUTION
Log in or sign up to see answer
Become an EE member today
7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
on gnu tar you could just add the
"--owner USER" to the tar command.
Is your problem that you've already done the restore and now the ownerships are wrong?
In that case, as root do:
cd ~"newuser"; chown -R "newuser" .
Then all the files in the "newuser" tree will be owned by "newuser"
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
tar -zxvf filename.tar.gz | xargs chown userid.userid
No actually I think you'll have to filter that but you get the idea?
Plans and Pricing
Certified Expert Program
© 1996-2022 Experts Exchange, LLC. All rights reserved. Covered by US Patent