Linux Terminal Command: chgrp

The chgrp command is an essential tool in User & Permission Management. In this tutorial, we will explore what chgrp does, look at everyday examples, and cover advanced options to supercharge your command-line workflow.


Concept & Explanation

The chgrp command updates the active group owner of files and directories. Useful for shared group workspaces.


Common Options & Syntax

chgrp [options] [arguments]

Here are the most common flags used with chgrp:


1. Interactive Example (Simple)

Here is how most people run the command:

# Example
chgrp developers codebase.git

What it does: Changes the group owner of ‘codebase.git’ to ‘developers’.


2. Power-User Example (Advanced)

For scripting and advanced diagnostics, use this configuration:

# Advanced
chgrp -R --reference=master_dir target_dir/

What it does: Recursively sets the group of ’target_dir’ to match the group of ‘master_dir’.


⚙️ Warning & Common Pitfalls

[!WARNING] You can only change file groups to groups you are currently a member of, unless you run the command as root using sudo.


Here are some related posts on cli_tty1 you might want to check out: