What is the purpose of the umask command in Linux?
In Linux, the umask command is used to set the default permission mask when creating new files or directories.
The permission mask determines the default permissions applied when creating a new file or directory. The umask command restricts access for other users to new files or directories by setting a permission mask.
Specifically, the umask command removes the specified permission bits from existing permissions and applies the remaining permissions to new files or directories. By default, the umask command value is 022, which removes write permission (2) and execute permission (2).
By setting the umask value, users can customize default permissions. For example, setting the umask to 002 can maintain read and write permissions for the owner, group users, and other users, while stripping away execute permissions for other users.
The syntax of the umask command is as follows:
umask [options] [mask]
In this case, the mask is a three-digit octal number that represents the permission mask. Each digit represents the permission bit for the “owner/group user/other user” respectively.
By using the umask command, users can control default permissions, thus increasing or restricting other users’ access to new files or directories.