The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group


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:

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:

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:
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.
A pathname of a file whose group ID is to be modified.


Not used.




The following environment variables affect the execution of chgrp:
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.
If set to a non-empty string value, override the values of all the other internationalisation variables.
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).
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
Determine the location of message catalogues for the processing of LC_MESSAGES .




Not used.


Used only for diagnostic messages.






The following exit values are returned:
The utility executed successfully and all requested changes were made.
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.






chmod, chown, the XSH specification description of chown().

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]