unmask Command in Linux

Learn via video courses
Topics Covered

Build an AI-First Career, Master the Complete Skillset

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program
NSDC Certified

AI Forward Deployed Engineer Program

Full-stack engineering, production AI and client-facing consulting

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program

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.
Sharpen Your Fundamentals with Free Learning

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------).

How Scaler Transformed Careers in Different Fields

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

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

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

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.