Operating System - HP-UX
1819682 Members
3575 Online
109605 Solutions
New Discussion юеВ

How do I recursively chown on a file.

 
Thomas Amwoza
Occasional Contributor

How do I recursively chown on a file.

I changed a UID on my system and I am
trying to run a command that will find
all of the files owned by the old UID
and chown them to the new UID. Here
is the command I have been using:

find /proj/hdl -user 221 -exec chown jcox +

Where /proj/hdl is the top-level directory,
221 is the old UID,
and jcox is the new login name.

However, it does not appear to be working.
Is there a better way to implement this?
6 REPLIES 6
MARTINACHE
Respected Contributor

Re: How do I recursively chown on a file.

can you try :

find /proj/hdl -user 221 -exec chown jcox + {} ;
Patrice MARTINACHE
James R. Ferguson
Acclaimed Contributor

Re: How do I recursively chown on a file.

Hi:

# find /proj/hdl -user 221 -exec chown {} jcox \;

BTW: A convenient option of 'chown' is the recursive option (-R). You can change the ownership of whole the contents of a directory like this:

# chown -R jcox /proj/hdl

...JRF...
Thomas Amwoza
Occasional Contributor

Re: How do I recursively chown on a file.

Curiously, the top command is showing the
process is in a SLEEP state. And when I
examine the files it does not appear to be
doing anything.
Robert Gamble
Respected Contributor

Re: How do I recursively chown on a file.

Thomas,

FYI: When running a top, almost all processes should be in a sleep state, because when top reports to the screen, it is running, not the process you are monitoring.

Good Luck!
James R. Ferguson
Acclaimed Contributor

Re: How do I recursively chown on a file.

Thomas:

Corrected syntax and more info:

# find /proj/hdl -user 221 -exec chown jcox {} \;

BTW: A convenient option of 'chown' is the recursive option (-R). You can change the ownership of the contents of a directory like this:

# chown -R jcox /proj/hdl

You may note also, that 'exec' (in the first example, above) can be fairly slow. This is because a process is spawned for each file or directory. A faster, less resource-intensive way is:

# find /proj/hdl -user 221|xargs chown jcox

...JRF...
Leigh Ann Vaigneur
Occasional Advisor

Re: How do I recursively chown on a file.

I typicality am changing all the files and directories in a particular directory but this is the command I use.

find . -print | xargs chown username

see if it helps.

Leigh Ann