Latest web development tutorials

Linux chgrp command

Linux command Daquan Linux command Daquan

Linux chgrp command is used to change the file or directory belongs.

On UNIX systems, the family, control of the file or directory permissions to the owner and their group to manage. You can use chgrp command to change file and directory belongs to the group, is set up using the group name or group identification code can be.

grammar

chgrp [-cfhRv][--help][--version][所属群组][文件或目录...] 或 chgrp [-cfhRv][--help][--reference=<参考文件或目录>][--version][文件或目录...]

Parameter Description

-c or --changes effect similar "-v" argument, but only in return for some of the changes.

-f or --quiet or --silent does not display an error message.

-h or --no-dereference symbolic links to files only be modified without changes to any other relevant documents.

-R Or --recursive recursive processing, all files and subdirectories in the specified directory be dealt with.

-v or --verbose display during the execution of instructions.

--help online help.

--reference = <reference to the file or directory> belongs to a group specified file or directory and all of their group set to reference the same file or directory.

--version display version information.

Examples

Example 1: change the group properties 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

"Log2012.log" belonging group has been changed to bin

[root@localhost test]# ll
---xrw-r-- 1 root bin  302108 11-13 06:03 log2012.log

Description: log2012.log file changed from the root group bin Groups

Example 2: change the group properties file according to 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

Description: Change the file log2013.log group attributes such documents log2013.log group attributes and references the same property group log2012.log

Linux command Daquan Linux command Daquan