Interview Question | What is Umask | User Mask or User file creation MASK in Linux | Linuxtopic

umask calculator, umask 0022, umask, umask in linux, chmod, stiky bit,
UMASK - Default file and folder Permission
What is Umask ?
What is stiky bit ?
What is default Umask Permission of File ?
What is default Umask Permission of directory ?
How to Calculate UMASK ?

UMASK (User Mask or User file creation MASK) is the default permission of the file and directory. we can check default umask permission using "umask" command.
Output of umask something like 0002 or 002. default umask value of system is 002 ( Normal User ) or 022 ( Root)

Default Umask File and Folder Permission 

Default permission for file is 666 because file required read and write permission only binary or script require execute permission &  directory default permission is 777.

how to Calculate UMASK permission for file and folder ?

Octal value : Permission

0 : read, write and execute
1 : read and write
2 : read and execute
3 : read only
4 : write and execute
5 : write only
6 : execute only
7 : no permissions

1) check default umask value by "umask" Command ( by default 0002 or 002 permission )

2) default file permission is 666 and folder permission is 777

formula is = (default file/folder permission) - (default system permission )

file = 666 - 002 = 664 permission will be set when you will create a file

folder = 777 - 002 = 775  Permission will be set when you will create a folder

How to change Umask default permission ?

we can setup umask in /etc/bashrc or /etc/profile file for all users.

Point :

The default umask 002 used for normal user. With this mask default directory permissions are 775 and default file permissions are 664.

The default umask for the root user is 022 result into default directory permissions are 755 and default file permissions are 644.

For directories, the base permissions are (rwxrwxrwx) 0777 and for files they are 0666 (rw-rw-rw).

3 - What is sticky bit ?

A sticky bit is a special permission of the directory, in this permission only owner of the file or root user can delete/rename the file no other user have permission to delete or rename it.

Sticky bit measure a security to avoid deletion of critical directory and their content. We can set sticky/setgid/setuid by “chmod” command

sticky/setgid/setuid -


1 = sticky bit

2 = setgid (set group id)

4 = setuid (set user id)

Command to set sticky bit on folder
chmod 1755 /stick/test


End of this UMASK  
 tutorial,  we need your support so i request you to please comment if something missed by me, share and like this post.