Operating System - HP-UX
1833730 Members
2511 Online
110063 Solutions
New Discussion

chown group of file to new owner

 
Fauziah Mahdan
Super Advisor

chown group of file to new owner

Hi all,
Is there any comamnd to change the file own by A to B in 1 command execute for all files under A to B.
Means no need to do one by one.
This is because 1 staff has create few files under her name and she resigned. I need to remove her id from uniox box and I don't want any impact like her file could not be read when her id gone.

Pls advice.
3 REPLIES 3
Matti_Kurkela
Honored Contributor

Re: chown group of file to new owner

The UNIX way: there are lots of tools, each of which will do one thing. To accomplish greater things, you join two or more of the tools together.

In this case, you'll need "find" to find the files that must be changed, and "chown" to make the change.

find / -user A -exec chown B {} \+

will search through the entire system, and change the ownership of all the files and directories owned by user A to user B.

MK
MK
Ramesh S
Esteemed Contributor

Re: chown group of file to new owner

Peter Nikitka
Honored Contributor

Re: chown group of file to new owner

Hi,

if all files and dirs reside under a list of directories AND all files and dirs should be changed (even if they have different owner/group), you can call
chown -R newuser:newgrp dir1 dir2 ...

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"