in the LUnix system, the control of the permissions of a file or directory is managed by the owner and the group being sued. You can use the CHGRP command to change the file and directory to belong to the group, this way with the group name or group identification code can be. The CHGRP command is the abbreviation for change Group! The group name to be changed must be in the/etc/The group file exists within the line. 1. Command format:chgrp[ options] [group] [file]2. Command function: The CHGRP command can change the group to which the file or directory belongs by using the group name or the group identification code. The usage permission is superuser. 3. Command parameters: Required Parameters:-C output Debug information When a change occurs-f do not display error messages-R handles all files in the specified directory and its subdirectories-v Run-time display detailed processing information--dereference acts on the point of a symbolic link, not the symbolic link itself--no-The dereference acts on the symbolic link itself by selecting parameters:--reference=< file or directory >--Help Display assistance information--version displays release information4. Use instance: Instance 1: Change the file's Group Properties command:chgrp-v bin log2012.log output: [[email protected] test]# ll---xrw-r--1Root root302108 One- - .:GenevaLog2012.log[[email protected] test]#chgrp-v bin Log2012.log The owning group of "Log2012.log" has changed to Bin[[email protected] test]# ll---xrw-r--1Root bin302108 One- - .:Genevalog2012.log Description: Change the Log2012.log file from the root group to bin group Instance 2: Changes the file's group Properties command according to the specified file:chgrp--reference=log2012.log log2013.log output: [[email protected] test]# ll---xrw-r--1Root bin302108 One- - .:GenevaLog2012.log-rw-r--r--1Root root A One- - .:GenevaLog2013.log[[email protected] test]#chgrp--reference=log2012.log Log2013.log [[email protected] test]# ll---xrw-r--1Root bin302108 One- - .:GenevaLog2012.log-rw-r--r--1Root bin A One- - .:Genevalog2013.log Description: Change the group attribute of the file Log2013.log, make the group attribute of the file Log2013.log and the group attribute of the reference file Log2012.log same instance 3: Change the group attribute of the specified directory and all files under its subdirectory Command: output: [[email protected] test]# LLDRWXR-xr-x2Root root4096 One- - ,: theTest6[[email protected] test]# CD Test6[[email protected] test6]# ll---xr--r--1Root root302108 One- - ,: theLinklog.log---xr--r--1Root root302108 One- - ,: theLog2012.log-rw-r--r--1Root root A One- - ,: theLog2013.log-rw-r--r--1Root root0 One- - ,: theLog2014.log-rw-r--r--1Root root0 One- - ,: theLog2015.log-rw-r--r--1Root root0 One- - ,: theLog2016.log-rw-r--r--1Root root0 One- - ,: theLog2017.log[[email protected] test6]# CD. [Email protected] test]#chgrp-R bin Test6[[email protected] test]# CD Test6[[email protected] test6]# ll---xr--r--1Root bin302108 One- - ,: theLinklog.log---xr--r--1Root bin302108 One- - ,: theLog2012.log-rw-r--r--1Root bin A One- - ,: theLog2013.log-rw-r--r--1Root bin0 One- - ,: theLog2014.log-rw-r--r--1Root bin0 One- - ,: theLog2015.log-rw-r--r--1Root bin0 One- - ,: theLog2016.log-rw-r--r--1Root bin0 One- - ,: theLog2017.log[[email protected] test6]# CD. [Email protected] test]# LLDRWXR-xr-x2Root bin4096 One- - ,: theTest6[[email protected] test] #说明: Change the group attribute instance of the specified directory and all files under its subdirectories 4: Change the file group properties by Group ID command:chgrp-R -test6 output: [[email protected] test]#chgrp-R -Test6[[email protected] test]# lldrwxr-xr-x2Root Users4096 One- - ,: theTest6[[email protected] test]# CD Test6[[email protected] test6]# ll---xr--r--1Root Users302108 One- - ,: theLinklog.log---xr--r--1Root Users302108 One- - ,: theLog2012.log-rw-r--r--1Root Users A One- - ,: theLog2013.log-rw-r--r--1Root Users0 One- - ,: theLog2014.log-rw-r--r--1Root Users0 One- - ,: theLog2015.log-rw-r--r--1Root Users0 One- - ,: theLog2016.log-rw-r--r--1Root Users0 One- - ,: theLog2017.log[[email protected] test6] #说明: Change the file group properties through the group ID, 100 is the Users group identification number, specific groups and group identification code can go toView in/etc/group file
Linux Command Learning Note: chgrp command