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.
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.
chgrp [OPTION]... GROUP FILE... chgrp [OPTION]... --reference=RFILE FILE...
If you want to know more options of chgrp
How to use chgrp to change group permission?
If you want to change file or directory group then you can follow this
chgrp [group-name] nameoffile
Now I’ll show you in my case you can see shen is the group
To change group in my case i’ll choose root as another group
$ sudo chgrp root nameofile
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
chgrp -R [group][directory-path]
In this case all directories and files are under group of shen and we want to change group to root
$ sudo chgrp -R root ./
You can see the changes now all folders and files under root group.
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.
A man with a tech effusive, who has explored some of the amazing technology stuff and exploring more, While moving towards, I had a chance to work on Android Development, Linux, AWS, DevOps with several Open source tools.
One of my life mottos “Always be lifelong Students.”