Translating Mnemonic Permissions to Numeric Permissions


The permissions of a file, as you've seen throughout this chapter, come in sets of threerwx, 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 binary000, 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) PERMISSIONS

BINARY EQUIVALENT

NUMERIC EQUIVALENT

---

000

0

--x

001

1

-w-

010

2

-wx

011

3

r-

100

4

r-x

101

5

rw-

110

6

rwx

111

7


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.




Unix(c) Visual Quickstart Guide
UNIX, Third Edition
ISBN: 0321442458
EAN: 2147483647
Year: 2006
Pages: 251

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net