How to use the chown command to change the owner of the Linux file

  

In the Linux command, the chown command can change the owner of the file. Generally, this command is used as the administrator of the system. The general user does not have permission to use it. The editor gives you a detailed introduction to the usage of the chown command.

System administrators often use the chown command after the files are copied to another user's directory, allowing users to have permission to use the file.

1. Command format:

The code is as follows:

chown [options]. . . [Owner][:[group]] file. . .

2. Command function:

Change the owner and group of files by chown. User name and user ID settings can be used when changing the owner or group of files. Ordinary users cannot change their own files to other owners. Its operating rights are generally administrators.

3. Command parameters:

Required parameters:

-c Display information about changed parts

-f Ignore error information

-h Fix symbolic links

-R Processes all files in the specified directory and its subdirectories

-v Displays detailed processing information

-deference acts on the symbolic link instead of the link file itself

Select parameters:

--reference="Directory or file" Set the specified directory/file as a reference and set the file/directory of the operation to the same owner and group of reference files/directories. Group

--from= "Current User: Current Group" Change only if the current user and group are the same as the specified user and group

--help Display help information < Br>

--version Display version information

4. Example:

Instance 1: Changing Owners and Groups

Command:

The code is as follows:

chown mail:mail log2012.log

Output:
Previous123Next page Total 3 pages

Copyright © Windows knowledge All Rights Reserved