Linux chgrp Command: Change a File's Group

chgrp only changes the owner group of a file or directory. It is used when you want multiple users to access the same work files with matching groups.

What is the chgrp command?

Even if the group ownership changes, the file's group permission bits are not automatically added. To actually allow shared access, you also need to check the read/write permissions of the target group and the pass-through permissions of the parent directory.

Basic syntax

chgrp [options] group file...

Installed implementations and options may vary depending on the distribution. Check the current system's description using man chgrp.

Examples

Change file group

Verify that the target group exists and that you have permission to change it.

sudo chgrp editors report.txt

Apply to multiple files

Only changes the specified files.

sudo chgrp editors draft.txt final.txt

Check before and after changes

View both group and permissions with stat.

stat -c '%U:%G %A %n' report.txt

Things to check after changing the group

chgrp changes only the group ownership while keeping the owner the same. The group in the example below must already exist, and the calling user must have permission to make the change.

chgrp developers demo.txt
stat -c '%G %n' demo.txt

Example output:

developers demo.txt

If you don't have permission, you may get an Operation not permitted error. Even if the owning group changes, whether you can access the file depends on the file's group permission bits and the current process's group membership. To keep the same group for new files in a shared directory, also check the directory's setgid bit.

Main Options and Format

Options/Format Description
-R Change recursively to subpaths.
-h Targets the group of the symbolic link itself.
--reference=file Uses the group of the referenced file.
-v Show detailed information on processed files.

Precautions when using

Even after changing only the group, Permission denied may appear. Check the execution permissions of the parent directory and the file's group permissions with ls -ld. Since chgrp -R has a wide scope and also considers symbolic link handling, run it only on the precise target.

Frequently Asked Questions

chgrp and chown: Are the groups the same?

Both can be used to change group ownership. If the goal is only to change the group, chgrp makes it clearer.

Official Documentation

You can check the exact behavior of the options and differences in implementation in the official chgrp documentation.

More in This Category
Linux ethtool Command: Inspect Network Link and Driver Settings

Linux ethtool Command: Inspect Network Link and Driver Settings

Learn how to inspect Network Link and Driver Settings with the Linux ethtool command, including practical examples, key options, and important precautions.

Linux join Command: Combine Files by a Common Field

Linux join Command: Combine Files by a Common Field

Learn how to combine Files by a Common Field with the Linux join command, including practical examples, key options, and important precautions.

Linux killall Command: Signal Processes by Name

Linux killall Command: Signal Processes by Name

Learn how to signal Processes by Name with the Linux killall command, including practical examples, key options, and important precautions.

Linux Tutorial / Understand systemd Services, Boot, and Logs

Linux Tutorial / Understand systemd Services, Boot, and Logs

Understand Linux boot stages and systemd units, distinguish active services from boot enablement, and inspect current-boot logs with systemctl and journalctl.

Best Linux Distributions for Web Servers: Ubuntu, Debian, or Rocky Linux?

Best Linux Distributions for Web Servers: Ubuntu, Debian, or Rocky Linux?

Compare Ubuntu Server, Debian, and Rocky Linux for web hosting based on support lifecycle, package freshness, documentation, operational stability, and application requirements.

Linux Directory Structure Explained: Purpose of Major Directories

Linux Directory Structure Explained: Purpose of Major Directories

Understand the purpose of major Linux directories such as /etc, /var, /usr, /home, /proc, and /sys, and learn where common system files belong.

Linux less Command: Browse and Search Long Text Files

Linux less Command: Browse and Search Long Text Files

Learn how to browse long files with Linux less, move forward and backward, search text, follow growing logs, preserve colors, and exit the pager.

Linux cmp Command: Compare Files Byte by Byte

Linux cmp Command: Compare Files Byte by Byte

Learn how Linux cmp compares two files byte by byte, reports the first mismatch, runs silently in scripts, limits ranges, and differs from diff and checksums.

Linux Tutorial / File Types and Metadata: ls, file, stat, and readlink

Linux Tutorial / File Types and Metadata: ls, file, stat, and readlink

Learn what ls, file, stat, and readlink each reveal about a Linux file, including type, size, timestamps, and symbolic-link targets.

How to Check IP Addresses on Linux

How to Check IP Addresses on Linux

Learn how to check private and public IP addresses on Linux, identify the active interface and route, and distinguish IPv4, IPv6, and externally visible addresses.