LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-29-2005, 10:44 AM   #1
marsguy
Member
 
Registered: Nov 2004
Distribution: Red Hat Enterprise & SuSe 10
Posts: 77

Rep: Reputation: 15
chown question


Hello ...

Suppose that I am root and I have a directory in my system called "tartar"

and there are a number of directories and files in that "tartar" directory.

I need to change all the ownership in the directory "tartar" and directories inside of it to let's say: a user called "tommy". BUT I need to change the ownership ONLY for files and directories that don't belong to root.

for example:

"tartar" contains directories (liberty) (cotag) (peace) (cheesecake) and files 1,2, 3. these directories and files have different ownership and the directory (peace) and the file "2" belong to root.

If I wanna change all owner ship to "tommy" no matter what I would have used the command.

# chown -R tommy.tommy tartar.

but I wanna exclude files and directories that belongs to root from the chown process.

can u help me please?


thanks in advance
 
Old 09-29-2005, 11:26 AM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
This looks like a job for... find.

Try this from the tartar directory:
Code:
find . ! -user 'root' -exec chown tommy '{}' \;
Note: You may need to run this as root. Be careful.
 
Old 09-29-2005, 11:48 AM   #3
marsguy
Member
 
Registered: Nov 2004
Distribution: Red Hat Enterprise & SuSe 10
Posts: 77

Original Poster
Rep: Reputation: 15
thank you so much

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
chown loopoo Linux - Newbie 5 08-09-2005 09:38 AM
Chown -R Jakeh2k1 Linux - General 3 10-31-2004 04:23 PM
chown - samba question smuh Linux - Newbie 5 09-15-2003 07:05 AM
chown Sathe Linux - General 13 10-14-2002 11:25 AM
chown? joetec Linux - Newbie 6 04-07-2002 04:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:04 AM.

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
Open Source Consulting | Domain Registration