Changing the owner/group within a directory

There are times when you want to change the owner/group of files within a directory to new owner/group. This can be achieved using the built-in UNIX/Linux find command.

The following is the command used to change owner from oldowner to newowner

find . -user oldowner -exec chown newowner {} \;

The following is the command used to change group from oldgroup to newgroup

find . -group oldgroup -exec chgrp newgroup {} \;

Refence:
http://www.softpanorama.org/Tools/Find/using_exec_option_and_xargs_in_find.shtml

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s