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? |
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 |
Thanks for the reply.
I just did find /www -gid 30 -exec chown apache {} \; It worked good. Thanks. |
All times are GMT -5. The time now is 06:41 PM. |