CHGRP(CHange GRouP) is one more command which is useful to change group associated to a file/folder from one group to other in a Linux box. This is sister command to chown which is used to change owner of the file/folder as well as group name associated with that file.
chgrp command syntax:
chgrp options groupname file/foldername
Learn chgrp with examples:
Example1: Change group name:sales of a file to other group name:hrgroup.
chgrp hrgroup file1
Example2: Give access permissions to a command so that the command can be executed by all users belonging to apache-admins
chgrp apache-admins /etc/init.d/httpd
Example3: Change group ownership all the files located in /var/apache to group:apache
chgrp -R apache /var/apache
Example4:Change group ownership forcefully
chgrp -f apache /var/apache
Difference between chown and chgrp
1) chown command is used to change ownership as well as group name associated to different one, where as chgrp can change only group associated to it.
2) Many people say that regular user only able to use chgrp to change the group if the user belongs to them. But it’s not true a user can use chown and chgrp irrespective to change group to one of their group because chown is located in /bin folder so every can use it with some limited access.
Usages of chgrp command:
1)Used to change group ownership from one group to other group for a file/folder
2)As a security measure if you want to give permissions to a command to some group you can use this command.
Latest posts by Surendra Anne (see all)
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018
- wget download a file to a directory in Linux/Unix - June 4, 2018
- GIT: How to compare two GIT branches? - June 3, 2018
- Online training on Linux Bash shell scripting - February 8, 2018