Skip to content

Click on each book below to review & buy on Amazon.

As an Amazon Associate, I earn from qualifying purchases.

CompTIA Linux+ XK0-005 - 2.1 - Linux Hardening: Setting Default umask

Securing a Linux environment involves implementing various best practices to protect sensitive data and enhance system integrity. One essential aspect of Linux hardening is configuring the default umask value. The umask determines the permissions set on newly created files and directories. This guide provides an overview of the purpose and use of setting the default umask in Linux and explores the relevant configuration files and concepts.

Understanding umask

The umask is a three-digit octal value that represents the permissions mask used when creating new files and directories. It subtracts the umask value from the default permission settings to determine the effective permissions.

Each digit in the umask value corresponds to a permission set: the first digit represents the permissions for the owner, the second digit represents the permissions for the group, and the third digit represents the permissions for others.

Configuration Files

The default umask value can be set in various configuration files depending on the Linux distribution and system setup. Here are some commonly used files:

  • /etc/profile: This file contains system-wide environment variables and settings. Modifying the umask value in this file affects all users on the system.
  • /etc/bashrc: This file is executed for interactive Bash shell sessions. Setting the umask value here affects all users who use the Bash shell interactively.
  • User-Specific Configuration Files: Users can set their umask value in their individual configuration files such as ~/.profile, ~/.bashrc or ~/.bash_profile. These settings override the system-wide defaults for individual users.

It can also be set in a drop in file within the /etc/profile.d/ directory. The best approach to set system wide umask is by using a drop in file called

Configuring the Default umask

To configure the default umask value, follow these steps:

  1. Identify the appropriate configuration file based on your system setup (e.g., /etc/profile, /etc/bashrc, or user-specific configuration files).

  2. Open the configuration file using a text editor.

  3. Locate the line specifying the umask value or add a new line if it doesn't exist.

  4. Modify the umask value according to your desired permissions. For example, umask 022 sets the default permissions to 644 for files and 755 for directories.

  5. Save the changes and exit the text editor.

  6. Apply the changes by either logging out and logging back in or restarting the affected services.


Configuring the default umask value is an important step in Linux hardening. By setting an appropriate umask value, system administrators can control the default permissions applied to newly created files and directories. This helps ensure that sensitive data remains protected and unauthorized access is restricted.

The umask value can be modified in configuration files such as /etc/profile, /etc/bashrc, or user-specific configuration files. By adjusting the umask value, administrators can customize the default permissions to align with their security requirements.

Taking the time to configure the default umask value as part of Linux hardening practices contributes to a more secure and controlled environment. It promotes the principle of least privilege and minimizes the risk of accidental exposure of sensitive information.

Support DTV Linux

Click on each book below to review & buy on Amazon. As an Amazon Associate, I earn from qualifying purchases.

NordVPN ®: Elevate your online privacy and security. Grab our Special Offer to safeguard your data on public Wi-Fi and secure your devices. I may earn a commission on purchases made through this link.