chgrp - Change file group ownership

Synopsis

chgrp [-R [ -H | -L | -P ]] [ -h ] group file ...

Description

You can use chgrp to set the group of file to the group identifier or profile specified by group.

To change the group identifier, you must have one of the following authorities:

  • The current user has *ALLOBJ special authority.
  • The current user is the owner of file and either one of the following:
    • The primary group of the job is group.
    • One of the supplemental groups of the job is group.

In addition, the current user must have *USE authority to the group profile specified by group.

By default, chgrp follows symbolic links and changes the group of the file pointed to by the symbolic link.

The -H, -L and -P options are ignored unless the -R option is specified. In addition, these options override each other and the command's actions are determined by the last one specified.

The group of a file cannot be the same as the owner of the file.

Options

-H
If the -R option is specified, symbolic links on the command line are followed. Symbolic links encountered in the tree traversal are not followed.
-L
If the -R option is specified, both symbolic links on the command line and symbolic links encountered in the tree traversal are followed.
-P
If the -R option is specified, no symbolic links are followed.
-R
If file is a directory, chgrp recursively changes the group of each file in the entire subtree connected at that point.
-h
Change the owner and group of a symbolic link instead of the file pointed to by the symbolic link.

Operands

The group operand specifies either a group identifier number or group profile name. The file operand specifies a path name to an object.

Exit status

  • 0 when successful and all requested changes were made.
  • >0 when an error occurred.
Examples
  1. Change the group to group profile "abbey" for the file "newgui.java".
    
    chgrp abbey newgui.java
    
  2. Change the group to group profile "managers" for the subdirectory "personal.dir" and all files and subdirectories below this directory.
    
    chgrp -R managers personal.dir
    
  3. Change the group to group identifier "442" for the file "memo.txt".
    
    chgrp 442 memo.txt