Back to course

37. Changing Group Ownership: The `chgrp` Command

Linux Basics: From Zero to CLI Hero

Reassigning the Group

While chown can change both user and group, the chgrp command (CHange GRouP) is specifically used to change the group ownership of a file or directory.

Syntax

chgrp [options] new_group file/directory

Basic Usage

To change the group ownership of report.txt to the accounting group:

bash $ chgrp accounting report.txt

Note on Permissions: A regular user can use chgrp only if they are a member of the new_group they are assigning. If not, sudo is required.

Recursively Changing Group

To change the group ownership for a directory and its entire structure:

bash $ sudo chgrp -R finance /mnt/shared_data