Chown changes the owner of the specified file to the specified user or group, the user can be either a user name or a user ID, a group can have a group name or a group ID, and a file is a space-separated list of files to change permissions, and wildcard characters are supported. System administrators often use the Chown command to give users permission to use a file after copying it to another user's directory.
1. Command format:
chown [Options] [owner]: [Group] File
2. Command function:
Change the file owner and group by Chown. You can use the user name and user identification number settings when you change the owner or group of the file. Ordinary users cannot change their files to other owners. Its operation permissions are generally administrators.
3. Command parameters:
Necessary parameters:
-C Displays information about the changed parts
-F Ignore Error messages
-H Fix Symbolic link
-R handles all files in the specified directory and its subdirectories
-V displays detailed processing information
-deference acts on the point of a symbolic link, not the linked file itself
Select parameters:
--reference=< directory or File > Specify the directory/file as the reference, the operation of the file/directory to the reference file/directory of the same owner and group
--from=< Current User: Current group > changes only if the current user and group are the same as the specified user and group
--HELP Display Help information
--version displaying version information
4. Usage examples:
Example 1: Changing Owners and groups
Command: Chown mail:mail 001.log
Example 2: Changing file owners and groups
Command: Chown root:001.log
Example 3: Changing file groups
Command: Chown:mail 001.log
Example 4: Changing the owner and group of all files in the specified directory and its subdirectories
Command: chown-r-v root:mail test
One Linux command per day)--chown command