When you create a file, you don’t have to decide permissions up front. Permissions have defaults.
Those defaults can be controlled and modified using the
umask with no arguments will show you the current umask, in this case
0022 mean? That’s an octal value that represent the permissions.
Another common value is
umask -S to see a human-readable notation:
In this case, the user (
u), owner of the file, has read, write and execution permissions on files.
Other users belonging to the same group (
g) have read and execution permission, same as all the other users (
In the numeric notation, we typically change the last 3 digits.
Here’s a list that gives a meaning to the number:
0read, write, execute
1read and write
2read and execute
4write and execute
Note that this numeric notation differs from the one we use in
We can set a new value for the mask setting the value in numeric format:
or you can change a specific role’s permission:
umaskcommand works on Linux, macOS, WSL, and anywhere you have a UNIX environment