Translating Mnemonic Permissions to Numeric Permissions

The permissions of a file, as you’ve seen throughout this chapter, come in sets of three—rwx, for read, write, and execute permissions. And, as we showed you, you set these permissions by specifying that each one is either “on” or “off.” For example, ugo+rwx sets read, write, and execute permissions to “on” for user, group, and other, while a+rw sets read and write to “on” for everyone, and a-x sets execute to “off” (indicated in directory listings with the -).

Rather than set permissions with letters and hyphens, however, you can translate them into numeric values, using 1 for “on” and 0 for “off.” So, rw-, with read and write “on” and execute off, would translate into the numbers 110. You could think of this as counting in binary—000, 001, 010, 011, 100, 101, 110, 111, with a 1 in each place that the permission is set to “on.”

Each of these combinations of on/off permissions (or binary numbers) can be expressed as a unique decimal digit between 0 and 7, as shown in Table 5.1. It is these decimal digits that you use to set permissions.

Table 5.1. Numeric Equivalents for Mnemonic Permissions
MNEMONIC (RWX) PERMISSIONSBINARY EQUIVALENTNUMERIC EQUIVALENT
---0000
--x0011
-w-0102
-wx0113
r-1004
r-x1015
rw-1106
rwx1117

To set permissions using numeric equivalents:

  • chmod 777 rowyourboat

    Type chmod followed by the desired permissions for user, group, and other using the numeric equivalents listed in Table 5.1, followed by the filename. In this example, we’ve used 777 to set read, write, and execute permissions to “on” for the user, group, and other.

    Or, for example, 724 would give the user full read, write, and execute permissions, the group only write permissions, and other only read permissions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset