E-Mail:
Get our new Windows 7 eBook (PDF) for $7 with 70+ Tips. Download Now!

Absolute Permission

  • No Related Post

Absolute Permission

We’ve talked some about permissions in Linux and the most commonly used syntax for setting or changing those permissions. Using the symbolic mode for setting permissions means that your changes can be as simple as:

    chmod u+x somefile

This example grants the [u]ser e[x]ecutable permissions on the somefile file. If you’re not already the owner of somefile, the change has to be made as root, as only root and owners can adjust permissions.

This syntax is fairly straightforward. However, as you dig deeper into Linux, it’s useful to have a working understanding of the more difficult permissions syntax, absolute mode. Though more users and developers are using symbolic mode, you’ll still often find absolute mode used in documentation. Whether you choose to use it or not, it’s good to have a general understanding.

To understand the absolute permissions mode in Linux, you first need to adjust your thinking. Absolute mode sets permission bits utilizing octal notation. Octal notation uses 8 unique symbols (0, 1, 2, 3, 4, 5, 6, 7) to represent three binary digits. This isn’t an entirely foreign concept to computer users, as nearly everyone understands that the binary system uses only 0 and 1 to represent digits. Though we’re most used to the base 10 or decimal format, octal is useful for transforming decimal to binary.

Absolute permissions in Linux consist of three levels of user permissions (user, group and other) each subdivided into three groups of file permission (read, write and execute). This is the same scheme we’ve seen in symbolic mode. These permissions are manipulated by setting appropriate bits using octal notation. Here’s a quick view of the user and file permissions, as well as the notation representing each:

User Group Other
read write execute read write execute read write execute
400 200 100 40 20 10 4 2 1

OK. Slide your chair back and take a breath. This isn’t nearly as complicated as it might look. Once you understand the bit representations (the bottom row in the table), you’re well more than halfway to understanding how to set absolute permissions in Linux. Let’s walk through some examples for clarity.

I’d like to set a file in my home directory to be both writable and executable by the tony group. My chmod command would look like this:

    chmod 730 somefile

The three-digit representation is actually the sum of each bit group. Referring to the above table, you’ll see that 700 (or 7xx) sets the user permissions to read write and execute. It’s the sum of 400+200+100. 30 (or x3x) sets the group permissions to write and execute - the sum of 0+20+10. 0 (or xx0) locks down the file for the other group, removing any permissions for read, write or execute. It’s the sum of 0+0+0. In short, you’re summarizing the bit values for each type of permission and each type of user into three single digits.

Let’s take another example. I’d like to set the user to read and write permissions, the group and others to read-only. Here’s the command:

    chmod 644 somefile

Again, the 6 represents 400+200, or read and write permissions for the user. The 4 represents 40, or read-only permissions for the group. And, the 4 represents, well, 4 - read-only permissions for others or the world.

For all the frightening talk of octal, binary, decimal and bits, setting absolute permissions in Linux isn’t so difficult after all. You just have to think a bit differently.

What Do You Think?

 
35 queries / 0.362 seconds.