04. Setting Default Permissions umask

When we create a file or directory, accession modes are applied by default. We can see and change these defaults with umask.

Default settings

To look at your current masking simply use the umask command.

$ umask

Since our umask is set to 0022, and the default file mode is usually 666, we have:

Original file mode
- rw- rw- rw-
- --- -1- -1-
- rw- r-- r--

Thus we see the canonical 644 file permission that we get when we create new files.

$ touch sampleFile.txt
$ ls -l sampleFile.txt
-rw-r--r-- 1 JohnDoe staff 0 Mar 30 18:34 sampleFile.txt

Changing umask

To change umask, simply pass the octal value as an argument (include a 0 for the file mode).

$ umask 0777
$ touch sampleFile2.txt
$ ls -l sampleFile2.txt
---------- 1 JohnDoe staff 0 Apr 01 18:34 sampleFile2.txt

Here, we would cannot do anything with our sampleFile2.txt because umask suppressed all its accession modes.

Aching back from coding all day?

Self-Massage Tool

Aching back from coding all day? Try Back Problems

Relieve spasms, tight muscles, trigger points and pressure points with the Body Back Buddy! This trigger point massage is designed to help you self-message any area of your body - especially those that are hard to reach. Keeping your muscles relaxes and out of contraction is importan in helping to reduce pain and prevent muscle injury.

$ Check price
29.9529.95Amazon 4.5 logo(3,443+ reviews)

More Back Problems resources

Take your Linux skills to the next level!

Command Line Kung Fu

Take your Linux skills to the next level! Try Linux & UNIX

Command Line Kung Fu is packed with dozens of tips and practical real-world examples. You won't find theoretical examples in this book. The examples demonstrate how to solve actual problems. The tactics are easy to find, too. Each chapter covers a specific topic and groups related tips and examples together.

$ Check price
14.9914.99Amazon 4.5 logo(27+ reviews)

More Linux & UNIX resources