Used to change the group to which a file or directory belongs
chgrp command is used to change the user group to which a file or directory belongs. This command is used to change the user group to which the specified file belongs. Among them, the group name can be the id of the user group or the group name of the user group. The file name can be a space-separated list of files whose groups are to be changed, or it can be a collection of files described by wildcards. If the user is not the file owner or superuser (root) of the file, the group of the file cannot be changed.
In the UNIX system family, the control of file or directory permissions is managed by the owner and the group to which it belongs. You can use the chgrp command to change the group to which files and directories belong. The setting method can be the group name or group identifier.
chgrp [options][group][file|directory]
-R recursively changes the group to which the specified directory and all subdirectories and files under it belong.
-c or --changes: The effect is similar to the "-v" parameter, but only the changed parts are reported;
-f or --quiet or --silent: do not display error messages;
-h or --no-dereference: Only modify the symbolic link file, not any other related files;
-H If the command line argument is a symbolic link to a directory, traverse the symbolic link
-R or --recursive: recursive processing, processing all files and subdirectories in the command directory together;
-L iterates through every encountered symbolic link to a directory
-P do not traverse any symbolic links (default)
-v or --verbose: displays the instruction execution process;
--reference=<reference file or directory>: Set all the groups of the specified file or directory to be the same as the group of the reference file or directory;
Change the user group of all files in /usr/meng
and its subdirectories to mengxin
chgrp -R mengxin /usr/meng
Change the group owner of file ah to newuser
[root@rhel ~]# chgrp newuser ah