Chmod changes the permissions of files or directories
Format chmod parameter file name
R-read w-write x-Execute
O-ower owner g-group owner group o-others
+ Add a permission
-Cancel a permission.
= Grant the given permission and cancel all original Permissions
We can see that the test2 permission has changed. Sometimes it is more difficult to use this method to change permissions. All Linux systems provide another numeric representation method. In Linux, r is represented by 4, w is represented by 2, and x is represented by 1. We can directly write numbers when modifying them.
Chown changes the owner of a file or directory
Chown User File Name
The premise is that this user must exist.
Here we can see that test2 is changed, but test3 is also changed, because the two are hard-linked files.
Chgrp changes the group to which a file or directory belongs
Format: chgrp user group file name
Prerequisites: This User Group must exist in the system.
Umask sets a mask that limits the size of the new file.
Format umask mask
In Linux, the default mask is 022. We directly enter the umask command, which displays 0022,
The first one here is the special permission, and the last three are the mask of our permissions. The mask is represented by a number with the 777 permission to remove the file. The default permission of our file is 755,777-755 = 022, so the mask here is 022. You can view the permissions through umask-S. The output result is as follows:
At the beginning, we created a file and a directory. After careful observation, we found that our directory permissions are 755, but our file permissions are 644, this is inconsistent with the default one. Is it wrong? This is because there are permission restrictions in Linux. By default, the x permission of the new file is removed. In the lower half of this section, we can modify the permission to create a file and directory example.
From: Meng xiangyue's column