Results 1 to 9 of 9
I am trying to create a bash script that will automatically find all the files owned by Root user (or any other user) and changed the ownership of these files ...
- 10-11-2008 #1Just Joined!
- Join Date
- May 2008
- Posts
- 10
changing all files owned by root and assigned to other user
I am trying to create a bash script that will automatically find all the files owned by Root user (or any other user) and changed the ownership of these files to an other user.
Is there is anybody who knows how to do this and can help?
Thanks,
- 10-11-2008 #2forum.guy
- Join Date
- May 2004
- Location
- arch linux
- Posts
- 18,096
Welcome to the forums!

Just curious... what would be the purpose for this script?oz
→ new members/users: read this first | new member faq
→ no private messages requesting computer support - post them on the forums!
→ please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.
- 10-12-2008 #3Just Joined!
- Join Date
- Aug 2007
- Posts
- 28
you can do this with 'find', you will find with google a lot of help here, the syntax isn't present at the moment, watch -exec... in conjunction with find...
- 10-12-2008 #4Just Joined!
- Join Date
- May 2008
- Posts
- 10
- 10-12-2008 #5
I don't know the answer to your question but I'm with ozar on this one because I think I know where he is going with this. Why would you want to change any file owned by root? Did you know that you can really truly hose your system if you did this? It sounds pretty hardcore to me, even malicious.
I do not respond to private messages asking for Linux help, Please keep it on the forums only.
All new users please read this.** Forum FAQS. ** Adopt an unanswered post.
- 10-12-2008 #6forum.guy
- Join Date
- May 2004
- Location
- arch linux
- Posts
- 18,096
oz
→ new members/users: read this first | new member faq
→ no private messages requesting computer support - post them on the forums!
→ please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.
- 10-12-2008 #7Just Joined!
- Join Date
- May 2008
- Posts
- 10
- 10-12-2008 #8
(sigh)
I'm guessing this guy's legit, and he'll soon find a way anyway. So:
Or, if you wish to change also the group name of the file's ownership to match the new user name, find the new user's group name and plug it into this:Code:find topdirectoryname -user fred -exec chown barney '{}' \;
And I stress this advice previously given by MikeTbob about doing this for files currently owned by root:Code:find topdirectoryname -user fred -exec chown barney:barneygroup '{}' \;
Another caution: Not only will this change the files under the specified directory, but it will change the directory itself, if the ownership matches.Did you know that you can really truly hose your system if you did this?
Hope this helps. Use this power not for evil, but for good.--
Bill
Old age and treachery will overcome youth and skill.
- 10-12-2008 #9Just Joined!
- Join Date
- May 2008
- Posts
- 10


Reply With Quote
