File and Folder Permissions
In Chapter 5, we looked at managing groups, users, and file permissions from the desktop. Here, you’ll learn how to do all that and more from the command line. Let’s recall the possible file attributes, which are:
No permissions
Execute only
Write only
Execute and Write
Read only
Execute and Read
Write and Read
Execute and Write and Read
I have numbered them from 0 to 7 because these values are used by the system to store the attributes in octal (base 8). Table 7-7 shows each of these attributes, with a checkmark indicating where an attribute is set.
Table 7-7. The eight possible file attribute values
Value | Read | Write | Execute |
---|---|---|---|
0 | |||
1 | ✓ | ||
2 | ✓ | ||
3 | ✓ | ✓ | |
4 | ✓ | ||
5 | ✓ | ✓ | |
6 | ✓ | ✓ | |
7 | ✓ | ✓ | ✓ |
Looking at these checkmarks, you’ll see that they actually represent the binary values for 0 through 7, like this:
0 = 000 1 = 001 2 = 010 3 = 011 4 = 100 5 = 101 6 = 110 7 = 111
The highest value that can be created from three binary digits is 7, and so this is how the octal system of file permissions came about.
But in Ubuntu Linux (as with Unix and other Linux distributions), there are actually three sets of attributes (known as permissions) for each file and folder: one for the owner of the file or folder, one for the group that is allowed to access it, and one for everybody else.
The Owner, Group, and World Attributes
With eight possible permutations of permissions (and three sets of them), there are 512 different possible permissions per file. So, how on earth does anyone, or even the computer, keep track of all ...
Get Ubuntu: Up and Running now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.