Closed Captioning Closed captioning available on our YouTube channel

How basic file permissions work: 2-Minute Linux Tips

Network World | Jul 8, 2019

In this Linux Tip, learn how to read and understand basic file permissions. Once you understand file permissions, you can analyze and reassign them.

Copyright © 2019 IDG Communications, Inc.

Similar
Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at basic file permissions – the settings that determine what you and others can do with a file. Can you read it, change it, run it or remove it? Can other users do the same? Let’s see how this works.
Each file has a series of permissions associated with it. The basic permissions are read, write and execute. They are set up in a series of bits. A bit on a disk can be set to 0 or 1, basically on or off. Each file has 9 bits that establish basic access. Here’s an example:
OK, two things to focus on. 1) Each 1 indicates that a permission is granted. 2) Each set of three bits is associated with a group – the file’s owner, the file’s group and everyone else.
We can see that the owner has read, write and execute permission. The group associated with the file has run and execute. Everyone else has no access at all.
If binary is converted to hex, 111101000 would be displayed as 750. In a number like binary 111, the first 1 has a value of 4, the second a value of 2 and the third a value of 1 – similar to 111 in decimal where the first 1 has a value of 100, the second 10 and the last 1.
When you first create a file, a set of permissions is established.
The settings might be the default on your system or might result from a setting in your account. To see these settings, run the umask command:
Then pause a moment and consider that this setting is called a “mask” for a good reason. That means that the values to be assigned will be the opposite of what you might expect. The “022” portion of the mask will cause newly created files to acquire permissions of 644. That might have been 755 except that execute permissions are never set by default. You have to explicitly assign them with a chmod command. As an example, the second 0 in the mask doesn’t assign 000 (or ---) to the file’s owner, but 110 (111 minus the execute bit).
That’s your Linux tip for today.
If you have questions or would like to suggest a topic, please add a comment below.
And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and NetworkWorld.com.
Popular
Featured videos from IDG.tv