chgrp(1)
Change the group ownership of files or directories.
Synopsis
chgrp [OPTION]... GROUP FILE...Description
chgrp changes the group owner of one or more files or directories to the specified GROUP. The group can be specified by name or numeric ID. Only the file owner or the superuser can change group ownership.
By default, chgrp does not follow symbolic links. Use -L or -P to control link behavior, and -R to recursively change group ownership of directories and their contents.
Common options
| Flag | What it does |
|---|---|
-R, --recursive | recursively change group ownership of directories and their contents |
-L, --dereference | follow symbolic links; change the group of the linked file, not the link itself |
-P, --no-dereference | do not follow symbolic links (default) |
-H | follow symbolic links on command line, but not those encountered recursively |
-v, --verbose | print information about files being changed |
-c, --changes | like verbose, but report only files that actually changed |
-f, --silent, --quiet | suppress error messages |
--reference=RFILE | change group to match that of RFILE instead of specifying GROUP directly |
Examples
change group ownership of myfile.txt to the staff group
chgrp staff myfile.txtchange group ownership to GID 1001
chgrp 1001 myfile.txtrecursively change group of /home/project and all contents to developers group
chgrp -R developers /home/projectrecursively change group to users and print all changes made
chgrp -v -R users /var/data/change group of newfile.txt to match the group of template.txt
chgrp --reference=template.txt newfile.txtchange group of all .log files to admin, reporting only those that changed
chgrp -c admin *.log