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?

Inversion Therapy Table

Aching back from coding all day? Try Back Problems

Stretch out your back and relieve your back muscles with inversion therapy. This device counteracts the forces of gravity on the body by decompressing and elongating the spine. By using this product just ten minutes a day, you can be well on your way to improved circulation and posture while relieving muscle aches, back pain and stress.

$$ Check price
119.98119.98Amazon 4.5 logo(1,700+ reviews)

More Back Problems resources

Take your Linux skills to the next level!

How Linux Works

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

In this completely revised second edition of the perennial best seller How Linux Works, author Brian Ward makes the concepts behind Linux internals accessible to anyone curious about the inner workings of the operating system. Inside, you'll find the kind of knowledge that normally comes from years of experience doing things the hard way.

$ Check price
39.9539.95Amazon 5 logo(114+ reviews)

More Linux & UNIX resources