Chown changes the owner of the specified file to the specified user or group. The user can be either a username or a user ID. A group can be a group name or a group ID; Files are Spaces separated by a list of files to change permissions. Wildcards are supported. The chown command is often used by system administrators to give users access to a file after copying it to another user’s directory.
Only file masters and superusers can use this command
Command syntax
Chown (option)(parameter)
Command options
- -c or — changes: effect similar to the “-v” parameter, but only the changed parts are reported;
- -f or –quite or — silent: does not display error messages;
- -h or –no-dereference: Modifies only symbolically linked files and does not modify any other related files;
- -r or — recursive: Processes all files and subdirectories in the specified directory at once
- -v or — version: Shows the instruction execution process;
- –dereference: The effect is the same as the “-h” parameter;
- — Help: Online;
- –reference=< > : 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: Displays version information.
The command parameter
User: group
Specify the owner and the working group to which it belongs. When theGroup:
, only changes the file owner;- Files: Specifies the list of files to change the owner and workgroup. Support for multiple files and targets, and shell wildcards.
Change the owner and group of a file
> chown deploy:deploy rumenz.txt
Change the owner and group of a file
Each user has a default or primary group. If a user creates a new file or directory, the primary group automatically becomes the group owner of the file. You can use the id command to list the default groups of users.
If you want to change the group ownership of a file to the user’s default group, you should keep the group name only after the colon.
> chown deploy: rumenz.txt
Omit the group (deploy:), which modifies both the owner and group of the file
Change only the generic group of the file
> chown :deploy rumenz.txt
Omitting the master (:deploy) will change only the group of the file’s genera
Changes the owner and group of all files in the specified directory and its subdirectories
> chown -R -v deploy:deploy rumenz
reference1.txt
The host group of the host group is modified2.txt
Of the genus and the genus group
> chown --reference=1.txt 2.txt
The original link: https://rumenz.com/rumenbiji/… WeChat official account: entry station