Linux chgrp command
Translation results:
file name
Linux chgrp commandsyntax
Function: The chgrp command is used to change the group to which a file or directory belongs.
Syntax: chgrp [-cfhRv][--help][--version][group][file or directory...] or chgrp [-cfhRv][- -help][--reference=<Reference file or directory>][--version][File or directory...]
Linux chgrp commandexample
Example 1: Change the group attribute of the file:
chgrp -v bin log2012.log
Output:
[root@localhost test]# ll---xrw-r-- 1 root root 302108 11-13 06:03 log2012.log[root@localhost test]# chgrp -v bin log2012.log
The group to which "log2012.log" belongs has been changed to bin
[root@localhost test]# ll---xrw-r-- 1 root bin 302108 11-13 06:03 log2012.log
Instructions: Change the log2012.log file from the root group to the bin group
Example 2: Change the group attribute of the file based on the specified file
chgrp --reference=log2012.log log2013.log
Output:
[root@localhost test]# ll---xrw-r-- 1 root bin 302108 11-13 06:03 log2012.log-rw-r--r-- 1 root root 61 11-13 06:03 log2013.log[root@localhost test]# chgrp --reference=log2012.log log2013.log [root@localhost test]# ll---xrw-r-- 1 root bin 302108 11-13 06:03 log2012.log-rw-r--r-- 1 root bin 61 11-13 06:03 log2013.log