Skip to main content

chgrp

The chgrp (change group) command changes the group ownership of a file or directory. While chown can also change the group, chgrp is specifically designed for this single task.

Basic Syntax

chgrp [OPTION]... GROUP FILE...

Common Options

OptionDescription
-R, --recursiveOperate on files and directories recursively.
-v, --verboseOutput a diagnostic for every file processed.
-c, --changesLike verbose but report only when a change is made.
--reference=RFILEUse RFILE's group rather than specifying a GROUP.

Real-world Examples

  1. Change the group of a file:

    chgrp developers script.sh
  2. Change the group of a directory and its contents recursively:

    chgrp -R editors /shared/documents/
  3. Match the group of another file:

    chgrp --reference=template.txt newfile.txt