Chmod permission settings

Source: Internet
Author: User
I. Syntax format: chmod [who] [opt] [mode] File/directory name

1. which indicates the object, which is one or a combination of the following letters:
U: indicates the file owner.
G: indicates the same group of users.
O: other users
A: indicates all users. 2. Opt indicates the operation, which can be:
+: Add a permission.
-: Cancel a permission.
=: Grant the given permissions and cancel the original permissions.
3. mode indicates the permission:
R: readable
W: writable
X: executable

For example, to add the read and write permissions for file a.txt to users in the same group:

Chmod g + RW a.txt

Ii. digit setting

The number setting rule is simpler: chmod [mode] File Name

The key is the mode value. At first many beginners will be confused. In fact, it is very simple. We regard rwx as a binary number. If there is 1, there is 0, then rwx R-x r--can be expressed:

111 101 100

Convert each three digits into a decimal number, that is, 754.

For example, we want to grant the permission for the.txt file:

Other users in the same group
Readable is yes
Writable is executable

Then, we first obtain the permission string RW-r -- Based on the table above, and convert it to the binary number 110 110 100, and then convert each three digits into a decimal number, we get 664, So we run the following command:

Chmod 664 a.txt

The calculation process is as follows:

1) 1 + 2 + 4 = 7

2) The user group with 2 + 4 = 6 permission bits should be set to 6 and can be read and written.

3) 4. Other users are readable.


The commonly used numeric value and its meaning:

-RW ------- (600) -- only the owner has read and write permissions.
-RW-r -- (644) -- only the owner has read and write permissions, while the owner and other users have only read permissions.
-Rwx ------ (700) -- only the owner has read, write, and execution permissions.
-Rwxr-XR-X (755)-the owner has the read, write, and execution permissions, while the owner and other users have only the read and execution permissions.
-Rwx -- X (711) -- the owner has read, write, and execution permissions, while the owner and other users have only execution permissions.
-RW-(666) -- all users have the permission to read and write files. This approach is not advisable.
-Rwxrwxrwx (777)-all users have read, write, and execute permissions. It is not advisable.

The following are two common settings for the directory:
Drwx ------ (700)-only the owner can read and write data in the directory.
Drwxr-XR-X (755)-All users can read this directory, but only the owner can change the contents in the directory.

Chmod permission settings

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.