What is the chgrp Command?
chgrp stands for change group. When you create a file or folder for your project, you might need to assign which group can access it. With this command, you can set which group owns the file or folder without affecting the owner. This way, you control which group of users can access or manage the file or folder.
Syntax:
chgrp [options] group filename
Options:
-
-R → Recursive
It changes the group of a folder and everything inside it, including all files and subfolders.
Parameters:
- group → Group of the file or folder
- filename → Name of the file or folder
Example:
Suppose you are working on a project with 5 people:
- You → the owner
- One person → a user
- The remaining people → a group
Using chgrp, you decide which group can access a file or folder. (Owner and permissions remain the same.)
Steps to Set Group Using chgrp:
Step 1: Open your terminal.
Step 2: Type sudo before the chgrp command.
Step 3: After entering this command, choose the group to assign.
Command
sudo chgrp developers file.txt
Output
Group of "file.txt" changed successfully.
Explanation
Here, developers is set as the group that can access the file.












