Linux attribute command-general Linux technology-Linux technology and application information. For more information, see the following section. 1 chmod ---- change the access mode of one or more files)
Chmod [options] mode files
Only file owners or privileged users can use this function to change the file access mode. Mode can be in the digital format or in the who opcode permission format. Which is optional. The default value is a (all users ). Only one opcode can be selected ). You can specify multiple modes separated by commas.
Options:
-C, -- changes
Only output the information of the changed File
-F, -- silent, -- quiet
When the chmod mode cannot be changed, the file user is not notified.
-- Help
Output help information.
-R, -- recursive
Recursively traverse sub-directories and apply modifications to all files and sub-directories in the directory
-- Reference = filename
Set the permission by referring to the filename permission.
-V, -- verbose
Whether the modification is successful or not, the information of each file is output.
-- Version
Output version information.
# Who
U
User
G
Group
O
Others
A
All users (default)
# Opcode
+
Add Permissions
-
Delete permission
=
Reassign Permissions
# Permission
R
Read
W
Write
X
Run
S
Set the ID of a user (or group)
T
Sets sticky bit to prevent files or directories from being deleted by non-owners.
U
Current User Permissions
G
Current permissions of the Group
O
Current permissions of other users
In most cases, we use three Octal numbers to indicate permissions. The first one is the owner permission, the second is the group permission, and the third is the permission of other users, each permission is determined by the sum of four (read), two (write), and one (execution) values. For example, 6 (4 + 2) indicates that you have the read and write permissions, and 7 (4 + 2 + 1) indicates that you have the read, write, and execution permissions.
You can also set the fourth digit, which is located before the three-digit permission sequence. The fourth digit is 4, 2, and 1, which means the following:
4. Set the user ID during execution to authorize the process based on the file owner, instead of the user who creates the process.
2. Set the user group ID during execution to authorize the process based on the file group, instead of the user who creates the process.
1. Set the adhesion position.
Instance:
$ Chmod u + x file: add the execution permission to the file owner.
$ Chmod 751 the file owner is assigned the read, write, and execute permissions (7) to the file owner, and the read and execute permissions (5) to the file group, assign execution (1) permissions to other users
$ Chmod u = rwx, g = rx, o = x file
$ Chmod = r file: Assign read permissions to all users
$ Chmod 444 file: Same as above
$ Chmod a-wx, a + r is the same as above.
$ Chmod-R u + r directory recursively assign read permissions to the owner of all files and subdirectories in the directory
$ Chmod 4755 sets the ID to assign read, write, and execute permissions to the owner, and assign read and execute permissions to the group and other users.
2 chgrp ---- modify the group to which the file or directory belongs
Chgrp [options] newgroup files/directorys
The group name can use the group ID or the group name in/etc/group. Only the file owner or privileged user (root) can change its group.
Options:
-C, -- changes
Only output the information of the changed File
-F, -- silent, -- quiet
If the file group attribute cannot be changed, users of the file are not notified.
-- Help
Output help information.
-R, -- recursive
Recursively traverse sub-directories and apply modifications to all files and sub-directories in the directory
-- Reference = filename
Set the group of the current file according to the group information of filename
-V, -- verbose
Output details
-- Version
Output version information.
Instance:
$ Chgrp root test: Change the group to which test belongs to the root group.
$ Chgrp-R mysql test recursively sets the group attributes of the test directory and all files and subdirectories in the directory to mysql
$ Chgrp root * set the group attribute of all files in the current directory to root.
3 chown-set the owner identity of one or more files or directories
Chown [options] newowner files/directorys
The new owner can be the user's ID or the login name in/etc/passwd. Chown can also accept the form newowner: newgroup or newowner. newgroup. Change the attributes of the group. If there is no group name after the periods and colons, the group is changed to the new owner group. Only the current owner of a file or directory has the right to change its attributes.
Options:
-C, -- changes
Only output the information of the changed File
-- Dereference
Trace Symbolic Link
-H, -- no-dereference
Change the owner identity of each symbolic chain, rather than the owner identity of the referenced File
-F, -- silent, -- quiet
If the file owner attribute cannot be changed, users of the file are not notified.
-- Help
Output help information.
-R, -- recursive
Recursively traverse sub-directories and apply modifications to all files and sub-directories in the directory
-- Reference = filename
Change the owner to the owner of the filename file.
-V, -- verbose
Output details
-- Version
Output version information.
Instance:
$ Chown root test: Improves the root user of the test File
$ Chown-R root test_directory recursively change all file owners in the test_directory directory to root
$ Chown -- dereference root test_link: Change the owner of the original file linked to test_link to root, and the owner of the linked file remains unchanged.
$ Chown -- no-dereference root test_link: Change the link file owner of test_link to root. The original file owner remains unchanged.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service