Getting Started with Linux: changing file permissions with chmod--go

Source: Internet
Author: User

Described in the previous how to view the properties of the file in Linux, in the Linux file permissions explained in detail we introduced the Linux file three identities and four kinds of permissions, three identities were:

    1. U: Owner of File
    2. G: The group to which the file belongs
    3. O: Other users

For each identity, there are four different permissions, namely:

    1. R: Permission to read files (read)
    2. W: Permission to write to file (write)
    3. X: Execute permission (execute)
    4. S: Special Permissions

In the Linux file permissions explained in detail, we know that there are two ways to represent file permissions in Linux, respectively, the number and symbol representation.

chmod changing file permissions in digital form

chmod 755 test.sh

Converts 755 into character form, Rwxr-xr-x, that is, the owner of the file, The owning group and other users can read and run the test.sh file, but only the owner can write to the file themselves, that is, the other person is not authorized to modify the test.sh file. (Of course, the root user does not have this limitation, who wants to change who, this is also an experience that embodies the supremacy of root account!) )

To change the permissions of the file through the mathematical form is relatively simple, as long as the implementation of the permissions required to give the file, and then call the chmod instruction, the call form is:

chmod New Permissions File list

chmod changing file permissions as characters

chmod +x test.sh

The mathematical form can change the file of all three identities of four permissions at a time, and the character form is more flexible, you can give a certain identity of a permission to set a separate, such as the above instruction is to give three kinds of identities to give execution permissions, you can also separate settings:

chmod u+x test.sh Only add executable permissions to the owner

chmod g+x test.sh Only add executable permissions to group identities

chmod o+x test.sh Only add executable permissions to other people

All of the above three directives are combined to be equivalent to the one above, which is the ability to turn on executable permissions for all identities, and you can do the following as well:

chmod a+x test.sh

The A here represents all of the 3 identities!

If you want to remove a certain permission from an identity, you only need to change the + to- can, for example, remove the executable permission for someone else's identity:

chmod o-x test.sh

For read, write and other permissions, follow the above way to practice more, chmod through the character of the file permissions to change the operation see the following table:

chmod U

G

O

A

+ (plus)

-(minus)

= (set)

R

W

X

File or directory

Finally, a comprehensive example, after a similar problem extrapolate can:

chmod u=rwx,g+rx,o-x test.sh

Transferred from: http://www.letuknowit.com/topics/20120408/change-file-attributes-on-linux.html/
Related Article

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.