TrumanWong

chown

Used to change the owner or group of a file or directory

Supplementary instructions

chown command changes the owner and group of a file or directory. This command can authorize a user to become the owner of the specified file or change the group to which the file belongs. The user can be user or user D, and the user group can be group name or group id. The filename can be a space-separated list of files, and the filename can contain wildcard characters.

Only the file owner and superuser can use this command.

grammar

chown(option)(parameter)

Options

-c or --changes: The effect is similar to the "-v" parameter, but only the changed parts are reported;
-f or --quite or --silent: Do not display error messages;
-h or --no-dereference: Only modify the symbolic link file without changing any other related files;
-R or --recursive: recursive processing, processing all files and subdirectories in the specified directory together;
-v or --version: displays the instruction execution process;
--dereference: The effect is the same as the "-h" parameter;
--help: online help;
--reference=<reference file or directory>: Set the owner and group of the specified file or directory to be the same as the owner and group of the reference file or directory;
--version: Display version information.

Parameters

User: Group: Specify the owner and working group to which it belongs. When ":group" is omitted, only the file owner is changed; Files: Specify the list of files to change owner and workgroup. Supports multiple files and targets, supports shell wildcards.

Example

Change the file owner of the directory /usr/meng and all files and subdirectories under it to liu:

chown -R liu /usr/meng