LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 02-23-2006, 03:31 PM   #1
linchat
Member
 
Registered: Aug 2004
Location: USA BABY!
Distribution: SuSe, Fedora
Posts: 61

Rep: Reputation: 15
Change Owner on many files how to?


I have a few thousand files spread through out a number of directories that need the owner and group changed. The problem is, it is not all files that need these changes. I copied the files from a susie to a fedora install and the user ids / group ids changed.

So what I need to do is find all files with uid 30 and change it to a user. Then I need to do the same based on gid. I tried the find command based on UID and it did not work correcly. The files that need to be changed do not show a user but a number because the users do not exist.

I tried
find -nouser -exec ls -l {} \;

But that returned everything with either group or owner without owner. That will not work. I need to find specific by group or user.

I tried also

find / -uid 30
But this returned everything.

Any thoughts?
 
Old 02-23-2006, 03:51 PM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
find / -uid 30 actually didn't return "everything" but probably did return a lot of things that are uid 30 (i.e. /proc, /var/tmp, etc). To be more manageable, try a directory with mixed files and see the output. For example, if you know you have mixed files in the home directory, try find /home/username -uid 30 also you can use -gid for the gid's...

Once you figure out how to find them all, you can setup a for loop to chown them. Basically it's something like for i in *; chown user:group $i; done
 
Old 02-23-2006, 04:14 PM   #3
linchat
Member
 
Registered: Aug 2004
Location: USA BABY!
Distribution: SuSe, Fedora
Posts: 61

Original Poster
Rep: Reputation: 15
Thanks for the reply.

I just did

find /www -gid 30 -exec chown apache {} \;

It worked good. Thanks.
 
  


Reply



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
how to change mysqld owner? bosewicht Linux - Newbie 2 10-03-2007 02:06 AM
How to change owner and group in a directory to include subdir and all files Lakota Linux - General 2 07-15-2004 09:35 AM
Change owner arubin Linux - Newbie 3 04-30-2004 12:23 PM
[APACHE] change upload owner Creak Linux - Software 0 03-14-2004 05:59 PM
Change owner juno Linux - General 3 01-08-2003 07:03 AM

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

All times are GMT -5. The time now is 02:43 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