I recently watched "Uncle Bird's Linux private dish", because he is Taiwanese, so the way of expression and the mainland is not the same, the Taiwanese said the file is basically equal to what we say the document.
When you create a new file under Linux, you do not have to set permissions, you will have a default permission. This default permission is how to come out, is based on preset permissions and umask.
The default permissions for a file are-rw-rw-rw-, which is 666 points, and the default permissions for the directory are drwxrwxrwx, which is 777, and what is umask. Umask is the thing that calculates default permissions with preset permissions.
Direct input Umask can query your operating system umask value, the default is generally 0022, mainly to see the three digits, 022,w score is 2, which means that the file's default permissions are-rwr--r--(644)
Visible is the corresponding preset permissions to remove the W permission, because the owner of the use of the number is 0, so the permissions unchanged.
Similarly, the default permissions for the directory are also preset permissions to remove 022, i.e. drwxr-xr-x (755)
To this, the default permissions for files and directories come out. This umask can be set according to your needs. The orders are simple, like umask 0003.
It should be noted that do not reduce the number of preset permissions on the umask corresponding numbers, so that the calculated results are not necessarily true. For example, the preset permission score for a file is 666, minus 003, and becoming 663 is-rw-rw--wx
Both the owner and the group have no permissions to execute, but others have ... So the calculation is wrong. Minus the permissions, not the numbers. This should be remembered. 003, is to remove the W and x permissions.
So the correct result should be-rw-rw-r---in fact, the effect of 0003 and 0002 here is the same. 002 This umask is more suitable for a small working group to work together on a project, the team members of the project's files have permission to modify.