This is the last article on permission command, we have explained you the chmod, chown, umask on how to use and when to use with precisely?
In chown article, we said the chgrp and chown both can use for changing ownership.
If you are new or you don’t know about chmod it advice you to go through the chmod first.
So,without further delay will start our topic.
Table of Contents
What is chgrp?
In short and simple the chgrp command we use in the Linux system to change the group ownership of a file, folder, or directory.
chgrp stands for change group ownership, chgrp usually hands-on when we want to change the group of file or directory.
Syntax
chgrp [OPTION]... GROUP FILE...
chgrp [OPTION]... --reference=RFILE FILE...
If you want to know more options of chgrp
chgrp --help
Examples
How to use chgrp to change group permission?
If you want to change file or directory group then you can follow this
Syntax
chgrp [group-name] nameoffile
Now I’ll show you in my case you can see shen is the group
![chgrp: Before group was shen](https://trendoceans.com/wp-content/uploads/2020/10/image-16.png)
To change group in my case i’ll choose root as another group
$ sudo chgrp root nameofile
![chgrp: After group was root](https://trendoceans.com/wp-content/uploads/2020/10/image-17.png)
Successfully, we have changed our group, Make sure to use sudo when you want to change group.
It is pretty simple command one more thing I’ll show you how to change ownership of a file or folder recursively
How to use recursively with chgrp command?
If you want to change group of the all directories or sub-directories that can be achieve by recursively method
Syntax
chgrp -R [group][directory-path]
Example
In this case all directories and files are under group of shen and we want to change group to root
![chgrp: All Folder and file are under shen group](https://trendoceans.com/wp-content/uploads/2020/10/image-18.png)
$ sudo chgrp -R root ./
You can see the changes now all folders and files under root group.
![chgrp: All Folder and file are under root group](https://trendoceans.com/wp-content/uploads/2020/10/image-19.png)
Conclusion
Through the chgrp command, you change the group permission, It is similar to chown command comparatively it is easy to use.
Even there are many options that you can use along-with chgrp command.
If you having any difficulty, Question, or specific topic which you want we should explain then please share with us.
![profile](https://trendoceans.com/wp-content/uploads/2023/01/profile.png)
A man with a tech effusive who has explored some of the amazing technology stuff and is exploring more. While moving towards, I had a chance to work on Android development, Linux, AWS, and DevOps with several open-source tools.