0% found this document useful (0 votes)
15 views

Umask Explanation

The umask command is used to set default permissions for new files and directories by masking bits from the default permissions. It displays or sets the current umask value which represents the permissions to be removed from the default permissions of 777 for directories and 666 for files. The umask value uses octal notation and only the last 3 digits are significant. Subtracting the umask value from the default permissions determines the actual permissions for new files and directories.

Uploaded by

Khushant rana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Umask Explanation

The umask command is used to set default permissions for new files and directories by masking bits from the default permissions. It displays or sets the current umask value which represents the permissions to be removed from the default permissions of 777 for directories and 666 for files. The umask value uses octal notation and only the last 3 digits are significant. Subtracting the umask value from the default permissions determines the actual permissions for new files and directories.

Uploaded by

Khushant rana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

UMASK command

Syntax: umask [options]


Def: This command is used to update the by default file and directory access
permissions such as read, write and execute permissions for user/owner, group
and others.
1. umask: simply writing umask without any option will display the by
default umask value. Eg. umask
2. umask [mode]: It sets the user file creation mask to [mode]. If [mode]
begins with a digit then it is interpreted as an octal number (means
permissions are defined in the absolute/numeric mode), otherwise it is
assumed to be a symbolic mode string like defined in chmod command.
3. umask –p: It displays the default umask value in a form that may be
reused as an input.
4. umask –S: It displays the output in the symbolic mode. But by default
umask always display the result as an octal number (in numeric mode).
Example1: Give read/write/execute permission to the user, and no permissions
to group or others. i.e. the permission for files will be 600, and for directories
will be 700.
$ umask 077
Example2: Give read/write/execute permission to the user, read/execute
permissions to group or others for directories and read-only permission to group
or others for other files. i.e. the permission for files will be 644, and for
directories will be 755.
$ umask 022
Important points to consider:
 The leading zero in umask mode is just to signify that it is an octal
number, or to give it look of a C-style octal number. Only the last 3 digits
are actually useful in umask which tell about the access permissions.
 For checking the access permissions which you are setting with umask,
you need to subtract the mode value (used with umask) digit wise from
‘777’ for a directory and ‘666’ for a file. For file it is ‘666’ because you
cannot provide the execute permissions to the files using umask. (Eg. for
files ‘000’ is same ‘001’ but for directories it is different)
Other useful commands
Linux Groups
There are two types of groups that a user can belong to:
 Primary or login group – is the group that is assigned to the files that are
created by the user. Usually, the name of the primary group is the same as
the name of the user. Each user must belong to exactly one primary
group.
 Secondary or supplementary group - used to grant certain privileges to a
set of users. A user can be a member of zero or more secondary groups.

1. List all the groups that currently logged in user belongs to: groups
2. List all the users which are present in your linux: cat /etc/passwd
3. List all the groups which are present in your linux: cat /etc/group
4. List all groups a specific user belongs to: groups [user name] (eg. groups
ubuntu)
5. To list members of a group: getent group [group name] (eg. getent group
adm)
6. Creating a new group: sudo groupadd [group name] (eg. sudo groupadd
testgrp)
7. Creating a new user: sudo useradd [user name] (eg. sudo useradd testusr)

You might also like