umask permissions explanation

what is umask?
umask is the default permissions for writing a file in the system

where the settings for umask?
1 – /etc/profile
2 – /etc/bashrc

3 – users can change umask in the fly via umask command

what is current umask value?
u can run the command “umask to get the value”

 

first bit zero for
4000 = SUID
2000 = SGID
1000 = sticky bit

how to calculate it

first, let’s create a file with root account that has umask 0022

 

the file wrote in permission 644, and our umask value is 0022

so here how to set the correct one
first, let’s assume we want to make the default files rwrwrw 666
r = 4
w = 2
so every sector for the owner, group, others
to get the correct umask number we will say
777 – x = 666
this is equal to
777 – 666 = x
x = 111
so our umask will be 111

example

 

 

2 to remove the write permeation

7 to remove all permeation

0 give it all permeations ¬†actually ( don’t implement any permeation ¬†try 000 ;))

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.