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