chgrp - change the file group ownership
chgrp [-R] group file ...
The chgrp utility will set the group ID of the file named by each file operand to the group ID specified by the group operand.For each file operand, it will perform actions equivalent to the XSH specification chown() function, called with the following arguments:
- The file operand will be used as the path argument.
- The user ID of the file will be used as the owner argument.
- The specified group ID will be used as the group argument.
Unless chgrp is invoked by a process with appropriate privileges, the set-user-ID and set-group-ID bits of a regular file will be cleared upon successful completion; the set-user-ID and set-group-ID bits of other file types may be cleared.
The chgrp utility supports the XBD specification, Utility Syntax Guidelines .The following option is supported:
- -R
- Recursively change file group IDs. For each file operand that names a directory, chgrp will change the group of the directory and all files in the file hierarchy below it.
The following operands are supported:
- group
- A group name from the group database or a numeric group ID. Either specifies a group ID to be given to each file named by one of the file operands. If a numeric group operand exists in the group database as a group name, the group ID number associated with that group name is used as the group ID.
- file
- A pathname of a file whose group ID is to be modified.
Not used.
None.
The following environment variables affect the execution of chgrp:
- LANG
- Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
- LC_ALL
- If set to a non-empty string value, override the values of all the other internationalisation variables.
- LC_CTYPE
- Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments).
- LC_MESSAGES
- Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
- NLSPATH
- Determine the location of message catalogues for the processing of LC_MESSAGES .
Default.
Not used.
Used only for diagnostic messages.
None.
None.
The following exit values are returned:
- 0
- The utility executed successfully and all requested changes were made.
- >0
- An error occurred.
If, when invoked with the -R option, chgrp attempts but fails to change the group ID of a particular file in a specified file hierarchy, it will continue to process the remaining files in the hierarchy. If chgrp cannot read or search a directory within a hierarchy, it will continue to process the other parts of the hierarchy that are accessible.
Only the owner of a file or the user with appropriate privileges may change the owner or group of a file.Some systems restrict the use of chgrp to a user with appropriate privileges when the group specified is not the effective group ID or one of the supplementary group IDs of the calling process.
None.
None.
chmod, chown, the XSH specification description of chown().