Detailed usage of the file/directory permission settings command chmod

Source: Internet
Author: User

chmod is a command for file/directory permission settings, which is frequently encountered in Linux, this post summarizes the detailed usage of chmod.


Linux/unix file call permissions are divided into three levels, namely the file owner user, group group, and other. U represents the owner of the file, G means that the owner of the file belongs to the same group (group), and O indicates that the other person, a means that all three are.

+ indicates an increase in permissions,-represents a cancellation permission, = Represents a unique set of permissions.

R means readable, w means writable, and X indicates executable.


To illustrate:

(1), the file file1.txt is set to all people can read:


(2), the file file1.txt is set to all people can read:
chmod a+r File1.txt  


(3), the file File1.txt and File2.txt is set as the owner of the file, and it belongs to the same group of persons can write, but others other than the person cannot write:
chmod ug+w,o-w file1.txt File2.txt  


(4), the ex1.py is set to only the owner of the file can perform:
chmod u+x ex1.py  


(5), the current directory of all files and subdirectories are set to anyone can read:



In addition chmod can also use numbers to represent permissions such as chmod 777 file

The syntax is: chmod ABC file

Each of the a,b,c is a number that represents the permissions of the user, Group, and other respectively.

R=4,w=2,x=1

To rwx the attribute then 4+2+1=7;

To rw-the attribute then 4+2=6;

To r-x the property, 4+1=7.


To illustrate:

chmod a=rwx file  and chmod 777 file  effect are the same
chmod ug=rwx,o=x file  and chmod 771 file  effect are the same
Use chmod 4755 filename to give this program root privileges


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Detailed usage of the file/directory permission settings command chmod

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.