ArticleDirectory
- What is umask?
- How to calculate the umask value?
What is the default permission for creating a file? How can I change the default permission?
What is umask?
When we log on to the system and create a file, there is always a default permission. How does this permission come from? This is what umask does. Umask sets the default permission for the user to create files, which is the opposite of CHMOD. umask sets the permission "complement", while chmod sets the File Permission code. Generally, set the umask value in/etc/profile, $ [home]/. bash_profile, or $ [home]/. profile.
How to calculate the umask value?
The umask command allows you to set the default mode when creating a file. Each type of user (file owner, users in the same group, and other users) has a number in the corresponding umask value. For files, the maximum value of this number is 6. The system does not allow you to grant the execution permission when creating a text file. You must use the CHMOD command to add this permission after the creation. Directory allows you to set the execution permission. For the directory, the maximum number of umask numbers is 7.
The command is generally in the form of umask NNN.
Where NNN is set to umask to 000-777.
We only need to remember that u m a s k is to "take" the corresponding bit from the permission. The following table compares umask values with permissions:
Umask file directory
--------------------
0 6 7
1 6 6
2 4 5
3 4 4
4 2 3
5 2 2
6 0 1
7 0 0
--------------------
For example, if the umask value is 022, the default directory permission is 755, and the default file permission is 644.