The umask
command in Linux is used to set the default file permissions for newly created files and directories. It helps define the permissions that are automatically applied when a file or directory is created.
Here’s an overview of how to use the umask
command:
- Basic Usage:
To set the default file permissions usingumask
, you can use the octal representation of the permission mask. Theumask
value is subtracted from the default permission value (usually 666 for files and 777 for directories) to determine the final permissions. For example:
umask 022
This command sets the default file permissions to 644
(666 – 022) and default directory permissions to 755
(777 – 022).
- Displaying the Current Umask:
To display the current umask value, simply typeumask
without any arguments. For example:
umask
This command will display the current umask value in octal format.
- Examples:
- Setting the umask value:
umask 027
This command sets the default file permissions to640
(666 – 027) and default directory permissions to750
(777 – 027). - Displaying the current umask value:
umask
This command displays the current umask value in octal format, such as0022
or0007
.
The umask
command allows you to define the default file permissions for newly created files and directories. It is particularly useful for maintaining consistent permissions across your files and directories.
Note that the umask
value is subtracted from the default permissions, so a higher umask value results in more restrictive permissions.
For more information about the umask
command and its options, you can refer to the manual page by typing man umask
in your terminal.