Linux file permissions modification

chmod command to modify file permissions

u indicates the owner of the file, g indicates those who belong to the same group as the owner of the file, o indicates people other than others, and a indicates all three.
+ Means adding permissions,-means canceling permissions, = means unique setting permissions.
r means readable, w means writable, x means executable, X means only when the file is a subdirectory or the file has been set as executable
-R: for all files and subdirectories in the current directory Make the same permission change (that is, change one by one in a recursive manner)

Make the file file1.txt accessible to everyone:

chmod ugo+r file1.txt

Make the file file1.txt accessible to everyone:

chmod a+r file1.txt

Set the files file1.txt and file2.txt as the owner of the file, which can be written by people in the same group as the file, but cannot be written by people outside of the group:

chmod ug+w,o-w file1.txt file2.txt

Set ex1.py to be executed only by the owner of the file:

chmod u+x ex1.py

Make all files and subdirectories in the current directory readable by anyone:

chmod -R a+r *

In addition, chmod can also use numbers to indicate permissions such as:

chmod 777 file

The syntax is:

chmod abc file

Among them, a, b, and c are each a number, representing the permissions of User, Group, and Other respectively.

r=4, w=2, x=1
if rwx attribute is required, then 4+2+1=7;
if rw- attribute is required, 4+2=6;
if rx attribute is required, 4+1=5

Guess you like

Origin blog.csdn.net/qq_43804080/article/details/107385737