The Linux chown (English full spelling: change owner) command is used to set the file owner and file association group. chown requires the permissions of the super user root to execute this command. chown changes the user and/or group ownership of each given file. If only the owner (username or numeric user ID) is provided, that user becomes the owner of each given file and the file group is not changed. If the owner is followed by a colon and the group name (or numeric group ID) with no space in between, the file's group ownership also changes. If the username is followed by a colon but no group name, that user becomes the owner of the file and the file's group is changed to that user's login group. If the colon and group are given but the owner is omitted, only the file group is changed; in this case, chown performs the same function as chgrp. If only a colon is given, or if the entire operand is empty, the owner or group has changed.
[root@s141 home]# chown --help
[root@s141 home]# chown --version
chown (GNU coreutils) 8.22
Copyright © 2013 Free Software Foundation, Inc.
License GPLv3 : GNU GPL version 3 or later http://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by David MacKenzie and Jim Meyering.
[root@s141 test]# touch 1.txt
[root@s141 test]# ll
total 0
-rw-r–r-- 1 root root 0 Nov 22 15:52 1.txt
drwxrwxr -x 2 test test 6 Nov 21 18:24 a
[root@s141 test]# chown test.test 1.txt
[root@s141 test]# ll
total 0
-rw- r–r-- 1 test test 0 Nov 22 15:52 1.txt
drwxrwxr-x 2 test test 6 Nov 21 18:24 a
Usage: chown [parameter] user[:group] file2. Parameter description
Parameter description | |
---|---|
New The user ID of the file owner | |
The user group (group) of the new file owner | |
Display information about changed parts | |
Ignore error messages | |
Fix symbolic links | |
Display detailed processing information | |
Process all files in the specified directory and its subdirectories | |
Display auxiliary instructions | |
Display version |
The above is the detailed content of How to use Linux chown command. For more information, please follow other related articles on the PHP Chinese website!