chmod modify permissions

chmod modify permissions

chmod [OPTION]... MODE[,MODE]... FILE... chmod [OPTION]... OCTAL-MODE FILE... #Refer to the permissions of the RFILE file and modify the FILE to be the same as RFILE chmod [OPTION ]... --reference=RFILE FILE...

who:u,g,o,a 
opt:+,-,= 
permission:r,w,x 
modify all permissions of the specified user 
u= g= o= ug= a= u=,g= 
modify the specified one User one or a certain permission 
u+ u- g+ g- o+ o- a+ a- +--R: recursively modify permissions


Mathematical authority


Octal permissions

The default special user umask is 022, the new file attribute is 644 owner:6 group:4 other:4 The new directory is 755 owner:7 group:5 other:5 The
default common user umask is 002, the new file attribute is 664 owner:6 group:4 other:4 The new directory is 775 owner:7 group:7 other:5 


file:

Ordinary user he, li management user root; other has no r permission

Ordinary user he, li management user root; others have no w authority

For ordinary users, check the file attributes, if they are in the group to which the file belongs, they have the corresponding attributes. The group to which the non-owner belongs, that is, other users, have the corresponding permissions for other.

For the root user (UID=0), a file can be viewed and modified without read/write permission, but it cannot be executed without execution permission.

The owner has no read and write permissions and cannot directly view or change the content of the file, but the file owner can modify the permissions by himself. After modifying the permissions with the chmod command, they can view or modify the file ---> chmod u+rw file name!
 

folder:

Ordinary users have read and execute permissions on the folder by default, and can enter the folder and view the file or directory information under the folder;

other only has read permission but not execute permission, as follows:

Can only see the file name under the folder, cannot see the metadata of the corresponding file, cannot enter the folder, and cannot delete or modify the file under the folder

other only has write permission

Even if you have write access to the folder, you can't modify the folder without execute access.

While other only has execute permission for the folder, you can enter the folder, but you cannot view the information under the folder or make changes in the folder.

Summary For the folder, you must have execute permission to have normal read and write operations.

Whether a file can be deleted has nothing to do with the permissions of the file itself, but with the permissions of the parent folder. As long as the folder permissions, as long as the user has permissions for the folder, w permissions can delete any file under the folder
(folder metadata is stored on the hard disk with the relevant permissions of the folder, and the data block pointed to by its pointer stores it The file name, folder name and corresponding inode information below, execute the delete command to delete the
corresponding information in the folder data block)

expand:

Root has no execution authority and cannot use the cat command.

Reminder: Try to avoid adding execution permissions to non-essential files.

 

 

 

Guess you like

Origin blog.csdn.net/weixin_42243133/article/details/115326236