Linux file management command-chown command

1. Function

The Linux/Unix operating system uses the chown command to change the owner of the specified file to the specified user or group.

Users can be usernames or user IDs; groups can be group names or group IDs.

Files are separated by spaces and support wildcards ( wildcards are a special sentence, mainly including asterisks (*) and question marks (?), which are used to vaguely search for files. When searching for a folder, you can use it to replace one or more A real character ; when you don’t know the real character or are too lazy to enter the full name, wildcards are often used instead of one or more real characters).

 

2. Grammar

chown [-cfvR] [--help] [--version] user[:group] file…

 

Three, parameter description

user: The user ID of the new file owner.

group: The user group of the new file owner.

-c: Display the information of the changed part.

-f: Ignore error messages.

-h: Repair symbolic links.

-v: Display detailed processing information.

-R: Process all files in the specified directory and its subdirectories

--help: display auxiliary instructions

--version: display version

 

Four, usage

Example 1: Set the owner of the test.txt text file to user, andtheusergroup of the group,and display the change information.

chown -c user:usergroup test.txt

Example 2 :Set the owner of all files and subdirectories in the test directory to user, the user group of the group, and display the change information.

chown -cR user:usergroup test/

 

Guess you like

Origin blog.csdn.net/weixin_43184774/article/details/106069102