Changes the group ownership of a file or directory.
chgrp [ -f ] [ -h ] [-R ] Group { File ... | Directory ... }
chgrp -R [ -f ] [ -H | -L | -P ] Group { File... | Directory... }
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.
Item | Description |
---|---|
-f | Suppresses all error messages except usage messages. |
-h | Changes the group ownership of an encountered symbolic link and not that of the file or directory pointed to by the symbolic link. |
-H | If the -R option is specified and a symbolic link referencing a file of type directory is specified on the command line, chgrp shall change the group of the directory referenced by the symbolic link and all files in the file hierarchy below it. |
-L | If the -R option is specified and a symbolic link referencing a file of type directory is specified on the command line or encountered during the traversal of a file hierarchy, chgrp shall change the group of the directory referenced by the symbolic link and all files in the file hierarchy below it. |
-P | If the -R option is specified and a symbolic link is specified on the command line or encountered during the traversal of a file hierarchy, chgrp shall change the group ID of the symbolic link if the system supports this operation. The chgrp utility shall not follow the symbolic link to any other part of the file hierarchy. |
-R | Descends directories recursively, setting the specified group ID for each file. When a symbolic link is encountered and the link points to a directory, the group ownership of that directory is changed but the directory is not further traversed. If the -h, -H, -L or -P flags are not also specified, when a symbolic link is encountered and the link points to a directory, the group ownership of that directory is changed but the directory is not traversed further. |
This command returns the following exit values:
Item | Description |
---|---|
0 | Successful completion. |
>0 | An error occurred. |
Attention RBAC users and Trusted AIX® users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.
chgrp staff proposals
The group access permissions for proposals now apply to
the staff group.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.Item | Description |
---|---|
/usr/bin/chgrp | The chgrp command |
/etc/group | File that identifies all known groups |