The 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. Where the group name can be either the ID of the user group or the group name of the user group. The file name can be a list of files separated by a space to change the generic group, or a collection of files described by a wildcard. If the user is not the file master or superuser (root) of the file, the group of the file cannot be changed.

The group name must be in
/etc/groupThere are

>cat /etc/group
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
ftp:x:50:
lock:x:54:
audio:x:63:
nobody:x:99:
users:x:100:
utmp:x:22:
mysql:x:27:
nginx:x:993:

The command format

CHGRP [options] [groups] file...

options

  • -c or — changes: effect similar to the “-v” parameter, but only the changed parts will be shown;
  • -f or –quiet or — silent: does not display error message;
  • -h or –no-dereference: Modifies only the symbolically linked file and not any other related files;
  • -r or — recursive: Processes all files and subdirectories in the command directory at once
  • -v or — verbose: Shows the execution of the command;
  • –reference=< > : sets the group of the specified file or directory to the same group as the group of the reference file or directory;

The command parameter

  • Group: Specifies a new job name;
  • Files: Specifies the list of files to change the group to which you belong. Multiple files or directories are separated by Spaces.

Change the generic group of a directory

> ls -al rumenz drwxr-xr-x 2 root root 59 Feb 3 23:39 rumenz > chgrp -v www rumenz > ls -al rumenz drwxr-xr-x 2 root www  59 Feb 3 23:39 rumenz

will
rumenzDirectory by
rootGroup to
wwwgroup

Changes the generic group of a directory, including all files in the directory

> chgrp -R www rumenz

Changes the group properties of a file based on the specified file

> chgrp --reference=1.txt 2.txt

Change the file
2.txtGroup properties that make the file
2.txtGroup properties and reference files
1.txtThe group properties of the

Change file group attributes by group identifier

> chgrp -R 27 ruemnz

So 27 is going to be
mysqlgroup

The original link: https://rumenz.com/rumenbiji/… WeChat official account: entry station