Tuesday, February 05, 2008

Linux : chgrp: Changes the group associated with a file

chgrp [options] group file-list

chgrp [options] ––reference=rfile file-list


The chgrp utility changes the group associated with one or more files.

Arguments

The group is the name or numeric group ID of the new group. The file-list is a list of the pathnames of the files whose group association is to be changed. The rfile is the pathname of a file whose group is to become the new group associated with file-list.

Options

––changes

–c

Displays a message for each file whose group is changed.

––dereference

Changes the group IDs of the files symbolic links point to, not the symbolic links themselves. The default is ––no-dereference.

––quiet or ––silent

–f

Prevents the display of warning messages about files whose permissions prevent you from changing their group IDs.


––no-dereference

–h

Changes the group IDs of symbolic links, not the files that the links point to (default).

––recursive

–R

Recursively descends a directory specified in file-list and changes the group ID on all files in the directory hierarchy.


––reference=rfile

Changes the group of the files in file-list to that of rfile.

––verbose

–v

Displays for each file a message saying whether its group was retained or changed.


Notes

Only the owner of a file or root can change the group association of a file. Also, unless you are root, you must belong to the specified group to change the group ID of a file to that group.

Examples

The following command changes the group that the manuals file is associated with; the new group is pubs.

$ chgrp pubs manuals 

No comments: