you are into Linux, you have seen different permissions like read, write, and
execute. When you create a directory or a file, you have seen it getting
created with default permission. Do you know from where it gets that default
value? How does the Linux kernel know that this is the default permission for a
directory or a file? Here comes the importance of umask command.
umask value is subtracted from maximum file permission of a file or directory.
This will give the default permission of a file/directory
command will show you the current umask value
take the last 3 digit as the value as the first value is used for a security
feature. So here, the umask is 002
us first look at the octal values of each permission in Linux
calculating the default permission, we have first look at the full permission
of a file is 666 and that of a directory is 777.
us change the umask to 0022
a file, we will have to subtract the umask value from the full permission I.e
666 –022 which is 644
The owner will have read and write permission
The group will have only read permission
Others will have only read permission
let us confirm this by creating a new file
can see the default permission is correct as we calculated
let us calculate the default permission for a directory.
–022 = 755
The owner will have full permission
The group will have read and execute permission
Others will also have read and execute permission.
us confirm this by creating a directory
can see that our calculation is correct,
are the steps to follow when you want to set the default permission of a file
DevOps Gurukul is one of the best training academies which provides Linux Course In Kochi. We have experienced training professionals who are passionate about grooming the right candidates to start their successful careers. Come learn Best online linux training in Kerala with us and have a bright future!