chgrp - Change the group owner of a file or directory

Format

chgrp [-fhR] group pathname ...

Description

chgrp sets the group ID to group for the files and directories named by the pathname arguments. group can be a group name from a group database, or it can be a numeric group ID (GID).

chgrp can be used only by the file owner or a superuser. The file owner must have the new group as his or her group or one of the supplementary groups.

chgrp also turns off the set-user-ID bit and set-group-ID bit of the named files and directories.

Options

-f
Does not issue an error message if chgrp cannot change the group ID. In this case, chgrp always returns a status of 0.
-h
Does not attempt to follow the symbolic link (or external link), but instead makes changes to the symbolic link (or external link) itself.
-R
If a pathname on the command line is the name of a directory, chgrp changes the group ID of all files and subdirectories in that directory. If chgrp cannot change some file or subdirectory in the directory, it continues to try to change the other files and subdirectories in the directory, but exits with a nonzero status.

Localization

chgrp uses the following localization environment variables:
  • LANG
  • LC_ALL
  • LC_CTYPE
  • LC_MESSAGES
  • NLSPATH

Exit values

0
You specified -f, or chgrp successfully changed the group ownership of all the specified files and directories.
1
Failure due to any of the following reasons:
  • Inability to access a specified file.
  • Inability to change the group of a specified file.
  • An unrecoverable error was encountered when you specified the -R option.
2
Failure due to any of the following reasons:
  • The command line contained an unknown option or too few arguments.
  • chgrp did not recognize the specified group.

Portability

POSIX.2, X/Open Portability Guide, UNIX systems.

The -f and -h options are an extension of the POSIX standard.

Related information

chmod, chown