• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero® Blog

NameHero® Blog

Web Hosting Tips & Resources From NameHero

  • AI Agents
    • OpenClaw
    • Claude Code
    • n8n
    • Hermes Agent
    • Open WebUI
    • Docker
  • Hosting
    • Web Hosting
    • WordPress Hosting
    • WooCommerce Hosting
    • Enterprise Hosting
    • Email Hosting
    • HeroicGuard
    • GPU Hosting
    • Website Builder
  • VPS
    • Managed VPS
    • Unmanaged VPS
    • Flex VPS
  • Reseller
  • Gaming
  • Domains
  • Account
  • Blog Home
  • Categories
  • Authors

Taking Control Of Default Permissions With Umask

CJ Saathoff

Published on: July 10, 2024

Categories: Linux Command Line 0

On Unix-like operating systems like Linux, the operating system consists of files and folders. With everything coming back to files and folders, permissions are important. Permissions for newly created files are just as important. Think about it, you don’t want to be constantly thinking about file permissions, and nor should you or your users. That is where umask comes into play, it allows for a safe default to be configured. In this blog post, we will discuss the umask command from what it is to how to use it to set a custom umask.

Table of Contents
  • What Is Umask?
  • What Is The Difference Between Chmod And Umask?
  • How To Calculate Umask Values
  • Umask Values
    • Are There Other Ways To Get The Umask?
  • How To Find The Current Umask Value?
  • How Do I Set A Custom Mask?
    • Temporally Set Umask For One User
    • Permanently Set Umask For One User
    • Permanently Set Umask For All Users
  • Conclusion
  • Additional Links

What Is Umask?

The umask command is a utility that is used to control the initial file permissions for newly created files and directories.

What Is The Difference Between Chmod And Umask?

Chmod changes permissions after a file or directory is created. Umask sets the default permission for files and directories before they are created to be applied as they are created.

How To Calculate Umask Values

The initial mask value is calculated by subtracting the umask value from the default value, which is 777 for directories and 666 for files (because files are never created with execute permissions).

So for example, if we have a umask of 022 (which is the default on many systems) the resulting permissions would be 755 for directories and 644 for files.

Note: Sometimes a umask will have four digits, e.g. 0022. The first 0 is for the setuid, setgid, and sticky bits.

Umask Values

Here are the values, keep in mind that these are being subtracted so a 2 would be removing write permissions.

  1. or — Which means no permission change
  2. or –x Which means removing the execute permission
  3. or -w- Meaning remove write permission
  4. or -wx Meaning remove write and execute permissions
  5. or r– Which means remove read permission
  6. or r-x To remove read and execute permissions
  7. or rw- To remove Read and write permissions
  8. or rwx To remove all three Read, write, and execute

Are There Other Ways To Get The Umask?

Here are two websites I found that allows you to calculate the umask without needing to do that math.

  • https://www.heuristic42.com/tools/unixperms/
  • https://wintelguy.com/umask-calc.pl

How To Find The Current Umask Value?

To find your calculated umask in octal notation run the following:

umask
Results of running umask command

To See umask in Symbolic notation value run:

umask -S
Results of running umask -S command

How Do I Set A Custom Mask?

In this section, we have a few different ways that umask can be set.

Feel free to use your preferred value, Octal or Symbolic.

Temporally Set Umask For One User

To temporally set a custom umask all you have to do is run the umask command with the mask value after it as shown below.

umask [mask_value]

This will take effect immediately but will only affect the current session.

Permanently Set Umask For One User

To change your default permissions for a single user we take the same command but add it to the user’s ~/.bashrc file.

echo "umask [mask_value]" >> ~/.bashrc

Make sure to replace [mask_value]

Be aware that this will only apply on the next login, see the Temporally Set Umask section if you want to apply before for a user.

Permanently Set Umask For All Users

To permanently override the default umask create a file at /etc/profile.d/umask.sh.

sudo echo "umask [mask_value]" > /etc/profile.d/umask.sh.

Make sure to replace [mask_value]

Be aware that this will only apply on the next login, see the Temporally Set Umask section if you want to apply before for a user.

Conclusion

In this post, we started by answering what is umask and how it differs from the chmod command. Moved on to how to calculate umask values, what the values mean, and how to get the current mask value. Finally, we wrap things up with how to set a custom mask.

Additional Links

Done reading and looking for additional webpages to read, why not check these out?

  • Other Chmod Posts
  • Other Chown Posts
  • Arch Linux Wiki Umask
  • Wikipedia Umask
CJ Saathoff

Embracing a lifelong passion for technology since childhood, CJ delved into the intricate workings of systems, captivated by the desire to understand the unknown. This innate curiosity led to his discovery of Linux, a revelation that resonated deeply. With more than 7 years of on the job experience, he’s honed his technical skills as a Geek and Senior Linux Systems Administrator.

Related Posts

How to Use Ufw to Open Port 80 in Linux

In Linux, particularly on Ubuntu system, here's how we can use ufw to open port 80. No need to mess with IPTables directly!

Git Rebase vs Merge vs Cherry-Pick: When to Use Each

Git has many tools for merging branches and commits. Rebasing, merging, and cherry-picking all have their uses.

Bash Signal Handling with Trap: EXIT, ERR, INT

Bash in Linux allows us to set functions that run when certain signals are generated - either by the script, or the shell. Here's how.

Symbolic Links vs Hard Links in Linux

Linux offers various methods for referencing files and directories through other files and directories, without creating copies of the original. If you have color coding enabled in your bash terminal, you might have seen some folders full of files of a different color from regular files. There’s a good chance that these are all symbolic […]

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!


Most Popular Posts

NameHero’s Recommended WordPress Plugin and Theme Setup

WordPress Hosting vs. Web Hosting – What’s The Difference?

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

Top Categories

  • WordPress
  • WordPress Tutorials
  • OpenClaw Hosting
  • Enterprise Hosting
  • WooCommerce
  • Web Hosting
  • Resellers
  • Website Security
  • Website Development
  • Website Performance
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero® proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Products
  • Web Hosting
  • Managed VPS Hosting
  • Unmanaged VPS Hosting
  • Flex VPS Hosting
  • WordPress Hosting
  • WooCommerce Hosting
  • Reseller Hosting
  • Enterprise Hosting
  • GPU Hosting
  • Email Hosting
  • HeroicGuard
  • Domains
  • Website Builder
  • AI Agent Hosting
Help & Support
  • NameHero Blog
  • NameHero Gaming Blog
  • Support
  • Help Center
  • Migrations
  • Affiliates
  • Gaming Affiliates
  • Call 1-855-984-6263
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2026 Name Hero, LLC. All rights reserved.
NameHero® is a registered trademark.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA