What is umask and how can it be helpful on linux server
When user create a file or directory under Linux or UNIX, it created with a default set of permissions. In most case, the system defaults may be open or relaxed for file sharing purpose. The user file-creation mode mask (umask) is used to determine the file permission for newly created files. It can be used to control the default file permission for new files.
It acts as a set of permissions that applications cannot set on files. It's a file mode creation mask for processes and cannot be set for directories itself. Most applications would not create files with execute permissions set, so they would have a default of
666
, which is then modified by the umask.
As you have set the umask to remove the read/write bits for the owner and the read bits for others, a default such as
777
in applications would result in the file permissions being 133
. This would mean that you (and others) could execute the file, and others would be able to write to it.
If you want to make files not be read/write/execute by anyone but the owner, you should use a umask like
077
to turn off those permissions for the group & others.
The default umask on Ubuntu is
0022
which means that newly created files are readable by everyone, but only writable by the owner:# umask 0022 # touch file # ls -l total 3340 -rw-r--r-- 1 root root 3412144 Nov 20 17:26 coreutils-8.22-18.el7.x86_64.rpm -rw-r--r-- 1 root root 0 Apr 7 04:00 file # umask 133 # umask 0133 # touch new-file # ls -l total 3336 -rw-r--r-- 1 root root 3412144 Nov 20 17:26 coreutils-8.22-18.el7.x86_64.rpm -rw-r--r-- 1 root root 0 Apr 7 04:00 file -rw-r--r-- 1 root root 0 Apr 7 04:00 new-file
0 Comments
Post a Comment