Linux Terminal Command: umask
The umask command is an essential tool in User & Permission Management. In this tutorial, we will explore what umask does, look at everyday examples, and cover advanced options to supercharge your command-line workflow.
Concept & Explanation
The umask command determines the default permissions assigned to newly created files and directories. It works as a subtraction mask from base permissions (666 for files, 777 for folders).
Common Options & Syntax
umask [options] [arguments]
Here are the most common flags used with umask:
- Simple Usage: Basic default commands.
- Detailed View: Shows diagnostic information.
- Advanced Actions: Can chain parameters for scripting.
1. Interactive Example (Simple)
Here is how most people run the command:
# Example
umask
What it does: Prints the current default permission mask in octal representation.
2. Power-User Example (Advanced)
For scripting and advanced diagnostics, use this configuration:
# Advanced
umask 0022
What it does: Sets default file permissions to 644 (666-022) and directories to 755 (777-022). This blocks write access for group and others.
⚙️ Warning & Common Pitfalls
[!WARNING] Umask limits permissions; it cannot add them. Setting
umaskonly lasts for the duration of the current shell session unless added to shell startup files.
🔗 Related Commands
Here are some related posts on cli_tty1 you might want to check out: