chgrp Command
Purpose
Syntax
chgrp [ -f ] [ -h ] [-R ] Group { File ... | Directory ... }chgrp -R [ -f ] [ -H | -L | -P ] Group { File... | Directory... }
Description
The chgrp command changes the
group of the file or directory specified by the File or Directory parameter to the group specified by the Group parameter. The value of the Group parameter
can be a group name from the group database or a numeric group ID. When a
symbolic link is encountered and you have not specified the -h or -P flags, the chgrp command
changes the group ownership of the file or directory pointed to by the link
and not the group ownership of the link itself.
Although the -H, -L and -P flags are mutually exclusive, specifying more than one
is not considered an error. The last flag specified determines the behavior
that the command will exhibit.If you specify the -h flag, the chgrp command has the opposite effect and changes the group ownership of the link itself and not that of the file or directory pointed to by the link.
If you specify both the -h flag
and the -R flag, the chgrp command
descends the specified directories recursively, and when a symbolic link is
encountered, the group ownership of the link itself is changed and not that
of the file or directory pointed to by the link.
Flags
Exit Status
This command returns the following exit values:
0 | Successful completion. |
>0 | An error occurred. |
Examples
- To change the group ownership of the file
or directory named proposals to staff:
chgrp staff proposals
The group access permissions for proposals now apply to the staff group. - To change the group ownership of the directory
named proposals, and of all the files and
subdirectories under it, to staff:
chgrp -R staff proposals
The group access permissions for proposals and for all the files and subdirectories under it now apply to the staff group.
No comments:
Post a Comment