$linuxjunkies
>

chgrp(1)

Change the group ownership of files or directories.

UbuntuDebianFedoraArch

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

FlagWhat it does
-R, --recursiverecursively change group ownership of directories and their contents
-L, --dereferencefollow symbolic links; change the group of the linked file, not the link itself
-P, --no-dereferencedo not follow symbolic links (default)
-Hfollow symbolic links on command line, but not those encountered recursively
-v, --verboseprint information about files being changed
-c, --changeslike verbose, but report only files that actually changed
-f, --silent, --quietsuppress error messages
--reference=RFILEchange 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.txt

change group ownership to GID 1001

chgrp 1001 myfile.txt

recursively change group of /home/project and all contents to developers group

chgrp -R developers /home/project

recursively 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.txt

change group of all .log files to admin, reporting only those that changed

chgrp -c admin *.log

Related commands