umask is a command that determines the settings of a mask that controls how file permissions are set for newly created files. It
also may refer to a function that sets the mask, or it may refer
to the mask itself, which is formally known as the file mode creation
mask. The mask is a grouping of bits, each of which restricts how its
corresponding permission is set for newly created files. The bits in the mask
may be changed by invoking the umask command
If no umask
were used then the default permission would be :
·
666
for directories
·
666
for files
The umask command using Octal value:
In this
mode umask permissions are not represented as characters
but a three digit octal number
The
table below gives numbers for all for permissions type:
Octal Value
|
Binary
|
Directory Permissions
|
File permissions
|
0
|
0
|
rwx
|
rw-
|
1
|
1
|
rw-
|
rw-
|
2
|
10
|
r-x
|
r--
|
3
|
11
|
r--
|
r--
|
4
|
100
|
-wx
|
-w-
|
5
|
101
|
-w-
|
-w-
|
6
|
110
|
--x
|
---
|
7
|
111
|
---
|
---
|
So if
our umask value is 022, then any new created files will by
default have the permissions 644 and
any new directories created will by default have the permissions 755
umask 022
(permission)
mkdir dir
(for making directory)
touch file
(create a file)
ls –l (list
directories & files)
The umask command using Symbols:
In the symbolic mode you can
set permissions of a specific owner. It makes use of mathematical symbols to
modify the file permissions
Operator
|
Description
|
+
|
Adds a permission to a file or
directory
|
-
|
Removes the permission
|
=
|
Sets the permission and overrides
the permissions set earlier
|
The various owners are
represented as :
User Denotation
|
|
u
|
User/Owner
|
g
|
Group
|
o
|
Other
|
a
|
All
|
We will be using permissions
in characters like rwx:
umask u=rw,g+wr,o= (permission)
The above umask command will
set the permissions for user to read and write, for group to read and write and
for other no permission
Umask (File Creation Mask) in Linux
Reviewed by vijay pratap singh
on
March 26, 2017
Rating:
No comments: