What is umask command in Linux?

The umask command in Linux is a built-in shell command that sets default permissions for newly created files and directories. It defines the permission bits that are not set for a newly created file or directory when a user creates them. Understanding umask is essential for managing file permissions effectively in a Linux environment.

By default, Linux uses a permission scheme that assigns read, write, and execute rights to the owner, group, and others. The umask value modifies these permissions by turning off specific permission bits. For example, if the default permissions for a file are 666 (read and write for owner, group, and others) and the umask is set to 022, the resulting permissions would be 644 (read and write for owner, read for group and others).


# Check current umask value
umask

# Set umask value
umask 027
    

umask Linux file permissions default permissions command line shell command