chgrp Command in Linux: Change File Group Ownership

The chgrp command changes the group ownership of files and directories in Linux. Each file is associated with an owner and a group, and the group determines which users share access permissions.
This guide explains how to use chgrp to change group ownership of files, directories, and symbolic links.
chgrp Command Syntax
The syntax for the chgrp command is:
chgrp [OPTIONS] GROUP FILE...GROUP- the name of the new group, or a numeric group ID (GID).FILE...- one or more files or directories.
Unlike the chown
command, which changes both user and group ownership, chgrp changes only the group.
Regular users can change the group of a file only if they own the file and only to a group they belong to. Use the id
command to list the groups your account belongs to. Administrative users can change the group ownership of any file.
To check the current group ownership of a file, use ls -l
:
ls -l filenameChange the File Group Ownership
To change the group ownership of a file or directory, invoke chgrp followed by the new group name and the target file:
chgrp www-data filenameThis changes the group of filename to www-data. By default, chgrp produces no output on success and returns exit code zero.
If the command is run by an unprivileged user who does not own the file or is not a member of the target group, you will get an “Operation not permitted” error. Use -f to suppress that error message.
You can pass multiple files and directories as arguments:
chgrp www-data file1 file2 dir1Use the -v (--verbose) option to print information about each file processed:
chgrp -v www-data file1 file2changed group of 'file1' from nginx to www-data
group of 'file2' retained as www-dataThe output shows both files because -v reports every processed path, including files whose group already matches the target group.
To print information only about files whose group actually changes, use -c (--changes) instead of -v:
chgrp -c www-data file1 file2You can also use a numeric GID instead of a group name:
chgrp 1000 filenameIf a group on the system is named with digits, prefix the ID with + to force chgrp to treat it as a numeric GID rather than a group name:
chgrp +1000 filenameTo find group names and their GIDs on the system, see the groups guide .
Change Symlink Group Ownership
By default, chgrp changes the group of the target that a symlink points to, not the symlink itself. For example:
chgrp www-data symlink1If the target cannot be followed because of permissions or protected symlink rules, the command may fail with a “cannot dereference ‘symlink1’: Permission denied” error. Do not disable symlink protection to work around this error.
To change the group ownership of the symlink
itself rather than its target, use the -h option:
chgrp -h www-data symlink1Recursively Change Group Ownership
To change the group ownership of all files and directories under a given directory, use the -R (--recursive) option:
chgrp -R www-data /var/wwwWhen used recursively, chgrp does not follow symbolic links by default. To also change the group of symlinks encountered during recursion, combine -R with -h:
chgrp -hR www-data /var/wwwTwo additional options control symlink traversal during recursive operations:
-H- if the argument tochgrpis a symlink, follow it into the directory it points to.-L- follow every symlink to a directory encountered during recursion.
Avoid -H and -L in most cases, as they can produce unexpected results or create security risks.
Quick Reference
| Task | Command |
|---|---|
| Change group of a file | chgrp GROUP file |
| Change group of multiple files | chgrp GROUP file1 file2 |
| Use numeric GID | chgrp +1000 file |
| Verbose output | chgrp -v GROUP file |
| Show only changed files | chgrp -c GROUP file |
| Suppress errors | chgrp -f GROUP file |
| Change symlink itself | chgrp -h GROUP symlink |
| Recursive change | chgrp -R GROUP /path |
| Recursive, change symlink objects | chgrp -hR GROUP /path |
Troubleshooting
Operation not permitted
You do not own the file or are not a member of the target group. Run with sudo, or use the id
command to verify your group memberships.
cannot dereference 'symlink': Permission denied
Symlink protection is enabled (/proc/sys/fs/protected_symlinks = 1). Use -h to change the symlink itself instead of the target.
invalid group
The specified group does not exist. Use getent group to list available groups, or see the groups guide
.
Group change has no effect on access
Check the file permissions with ls -l. The group must have the appropriate read, write, or execute bits set for the change to affect access.
FAQ
What is the difference between chgrp and chown?chown
can change both the user owner and the group of a file. chgrp changes only the group. The chown form chown :group file is equivalent to chgrp group file.
Can a regular user run chgrp?
Yes, but only to change the group of files they own, and only to a group they are a member of. Use the id
command to see which groups you belong to.
How do I change the group of all files in a directory?
Use the -R flag: chgrp -R GROUP /path/to/directory. This changes the group of the directory itself and all files and subdirectories inside it.
What does the + prefix mean in chgrp +1000 file?
It forces chgrp to treat 1000 as a numeric GID. A plain number like chgrp 1000 file already works as a GID; the + is only needed when a group is named with digits and you want to bypass the name lookup.
How do I verify the group was changed?
Run ls -l filename. The fourth column shows the group owner.
Conclusion
chgrp changes the group ownership of files, directories, and symbolic links. Use -R for recursive changes and -h to target symlinks directly rather than their targets.
For more on managing ownership, see the chown guide
, the groups guide
, and the guide on Linux file permissions
.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page