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
| Option | Description |
|---|---|
-R, --recursive | Operate on files and directories recursively. |
-v, --verbose | Output a diagnostic for every file processed. |
-c, --changes | Like verbose but report only when a change is made. |
--reference=RFILE | Use RFILE's group rather than specifying a GROUP. |
Real-world Examples
-
Change the group of a file:
chgrp developers script.sh -
Change the group of a directory and its contents recursively:
chgrp -R editors /shared/documents/ -
Match the group of another file:
chgrp --reference=template.txt newfile.txt