unmask Command in Linux
Transform Your Career
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
Overview
In Linux, the umask command is used to set the default permissions for newly created files and directories. The default permissions are based on the value of the umask. Understanding how the umask command works is essential for managing file permissions in Linux.
Linux umask Command Syntax
The syntax for the umask command is as follows:
Where:
- -S: Displays the current umask value in symbolic format.
- mode: Specifies the new umask value. This can be either an octal value or a symbolic value.
umask Command Options:
- -S: Displays the current umask value in symbolic format.
Example Usages
-
Display the current umask value in octal format.:
Output:
Explanation: The output 0022 means that newly created files will have permissions of 644 (-rw-r--r--) and newly created directories will have permissions of 755 (drwxr-xr-x).
-
Display the current umask value in symbolic format.:
Output:
Explanation: The output u=rwx,g=rx,o=rx means that newly created files will have permissions of 644 (-rw-r--r--) and newly created directories will have permissions of 755 (drwxr-xr-x).
-
Set the umask value to 077.:
Explanation: This command sets the umask value to 077, which means that newly created files will have permissions of 600 (-rw-------) and newly created directories will have permissions of 700 (drwx------).
Scaler Placement Report and Statistics
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
Tips
-
The umask value is subtracted from the maximum permission value (777 for files and 7777 for directories) to determine the default permission value for newly created files and directories.
-
The default umask value is usually set in the /etc/profile or /etc/bashrc file.
-
The umask value is inherited by child processes.
Advanced Use Cases of umask Command in Linux
-
Set the umask value for a specific user.:
Explanation: This command adds the line 'umask 077' to the user's .bashrc file, which sets the umask value to 077 every time the user logs in.
-
Set the umask value for a specific process.:
Explanation: This command sets the umask value to 022 for the duration of the 'command' process.
-
Use symbolic values to set the umask value.:
Explanation: This command sets the umask value to u=rwx,g=,o=, which means that newly created files will have permissions of 600 (-rw-------) and newly created directories will have permissions of 700 (drwx------). The u=rwx specifies that the user has read, write, and execute permissions, the g= specifies that the group has no permissions, and the o= specifies that others have no permissions.
Turn Learning into Career Growth
Conclusion
-
The umask command is used to set the default permissions for newly created files and directories in Linux.
-
The default permissions are based on the value of the umask, which is subtracted from the maximum permission value to determine the default permission value.
-
The umask value can be set using either an octal value or a symbolic value.
-
The umask value can be displayed in either octal or symbolic format.
-
The default umask value is usually set in the /etc/profile or /etc/bashrc file.
-
The umask value is inherited by child processes.




