LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-03-2011, 08:04 AM   #1
sungchoiok
Member
 
Registered: Oct 2010
Posts: 30

Rep: Reputation: 1
How would I be able to do this with "chown"?


I want to batch-change the file's ownership from person A's to person B's.

Like... in a directory containing 50 files of user A, I want to change all of their ownership to user B.

How would I be able to do this instead of chown-ing every file individually? My internet research was ineffective. Sorry if this post made you gasp. Thanks
 
Old 09-03-2011, 08:17 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,528

Rep: Reputation: 1056Reputation: 1056Reputation: 1056Reputation: 1056Reputation: 1056Reputation: 1056Reputation: 1056Reputation: 1056
You would do this recursively (logged in as root or su - or sudo):
Code:
cd directory
chown -R user.group .
Or, if you also want to change the directory ownership (say it's a home directory):
Code:
cd /home
chown -R user.group olduser
That's it.

Oops! Forgot one...

If you want to change only those files owned by A you could do this:
Code:
cd directory
find . -user A -exec chown B {} \;
You might also use chown B.group above if A was in a different default group than B.

Hope this helps some.

Last edited by tronayne; 09-03-2011 at 08:22 AM.
 
1 members found this post helpful.
Old 09-03-2011, 08:20 AM   #3
rich_c
Member
 
Registered: Apr 2008
Location: UK
Distribution: Mepis; Maemo; openSUSE
Posts: 384
Blog Entries: 74

Rep: Reputation: 81
This might help: http://www.mepiscommunity.org/node/390
 
Old 09-03-2011, 09:08 AM   #4
sungchoiok
Member
 
Registered: Oct 2010
Posts: 30

Original Poster
Rep: Reputation: 1
Thank you for your help. It worked.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Accidentally chown'ed and chmod'ed recursively from "/" dc_eros Slackware 6 06-25-2011 02:45 AM
chown - How do I set the permissions of an entire directory to "all" ? Evan. Linux - Newbie 2 01-17-2010 02:43 AM
All files/Directories owned by root (unable to change with "chown") KinnowGrower Linux - Desktop 8 10-22-2008 10:18 AM
Looking for a remote "chown" command ? MikeAtVillage Linux - Networking 4 05-23-2005 08:41 AM
Need Frontend to "chown" command TippyToes Linux - Software 3 11-24-2004 08:50 PM


All times are GMT -5. The time now is 10:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration