umask command in Linux and it perimeters

umask command in Linux and it perimeters

The umask command in Linux is used to set the default file permission mask for newly created files and directories. It helps control the permissions that are automatically applied when a new file or directory is created. The umask value is subtracted from the maximum permissions (usually 666 for files and 777 for directories) to determine the final permissions for the newly created files and directories.

Here’s a table explaining the umask command parameters and options:

ParameterDescription
-S, –symbolicDisplay the umask value in symbolic form (e.g., u=rwx, g=rx, o=rx).
-p, –prettyDisplay the umask value in a human-readable format (e.g., 0022).
–helpDisplay help information about the umask command.

Now, let’s see some examples of how to use the umask command:

  1. Set the umask value using an octal representation:
Bash
umask 0022

In this example, the umask value is set to 0022, meaning that newly created files will have permissions of 644 (666 – 0022) and directories will have permissions of 755 (777 – 0022).

  1. Set the umask value using a symbolic representation:
Bash
umask u=rwx,g=rx,o=rx

In this example, the umask value is set to u=rwx,g=rx,o=rx, meaning that newly created files will have permissions of 755 (777 – u=rwx) and directories will have permissions of 755 (777 – u=rwx).

  1. Display the current umask value in symbolic form:
Bash
umask -S

Output:

Bash
u=rwx,g=rx,o=rx

This command displays the current umask value in symbolic form, showing the permissions that will be removed when creating new files and directories.

  1. Display the current umask value in a human-readable format:
Bash
umask -p

Output:

Bash
0022

This command displays the current umask value in a human-readable format (octal representation).

By setting the appropriate umask value, you can control the default permissions for newly created files and directories, ensuring the security and privacy of sensitive data and avoiding unnecessary exposure of files and directories to other users.

Total
1
Shares

Leave a Reply

Previous Post
Pluggable authentication modules (PAMs) in Linux

Pluggable authentication modules (PAMs) in Linux

Next Post
gpg command in Linux and it perimeters

gpg command in Linux and it perimeters

Related Posts