View and update default permission masks using the UMASK command in Linux

Home > Search > Linux commands
  by

Umask removes permissions from newly created files and directories. Umask is system wide, meaning that the umask setting affects the entire system. You cannot have different umask settings for specific directories.

The umask command without any options will display a string of numbers. In this example, 0002 is displayed.

~]# umask
0002

 


Files

By default, files created in Linux have permission 0666 (-rw-rw-rw-). If the umask is 0002, you will subtract 0002 from 0666. The result of the subtraction is 0664, or -rw-rw-r--. In this example, umask removed the write permission from the other group.

 


Directories

By default, directories created in Linux have permission 0777 (-rwxrwxrwx). If the umask is 0002, you will subtract 0002 from 0777. The result of the subtraction is 0775, or -rwxrwxr-x. In this example, umask removed the write permission from the other group.

 


Changing the umask

The umask command followed by the new umask changed the umask. In this example, the umask is changed to 0000.

~]# umask 0000

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments