Untitled Document
chgrp Command

The chgrp command stands for Changing Group Owner , By deafult , the group owner of a file is the group to which the owner belongs . The chgrp command changes a file's group owner . In Linux a user can change the group owner of a file , but only to a group to which he/she belongs. User can belong to one or more groups.

1. Basic Example -

The following example , mangesh changes the group ownership of emp.csv to QA .Note that mangesh can reverse this action and restore the previous group ownership ( to dev) because he is still owner of the file and cosequently retains all rights related to it .

   chgrp QA emp.csv

2. Changing File owner recursively ( -R ) option -

Run below command to Change the owning group of /output/files, and all subdirectories, to the group QA.

-R -- operate on files and directories recursively. -h -- affect symbolic links instead of any referenced file. This is useful only on systems that can change the ownership of a symlink.

   chgrp -hR QA /output/files
Untitled Document