Title: Setting Octal Permissions
Course: CIS 121: Linux/UNIX I: Fundamentals ~ For IGNITE Review > Section: Learning Modules

Binary Numbers

Binary numbers are important in computing because they are all that a computer understands. They are the language of a computer. Binary numbers are made up entirely of zeros and ones. Each zero and one conveniently corresponds to a switch inside the computer that is either off or on. By grouping zeros and ones together, the computer can represent any type of instruction or data that we want it to process.

If the switch (bit) is turned on, the binary value is 1. If the switch (bit) is turned off, the binary value is 0.

Setting Octal Permissions

Most Unix administrators will use the octal system to talk about and set permissions. Look at the triplet bitwise, equating r to 4, w to 2, and x to 1. If the bit is set (1), the permission is granted. If the bit is not set (0), the permission is not granted. Adding up the number of binary bits set to 1 gives you the octal number for that set of permissions.  See the chart below for an illustration.

This makes 777 equal to rwxrwxrwx, and by the same logic, 654 mean rw-r-xr-- . The chmod command will accept these numbers.

paul@laika:~/perms$ chmod 777 permissions.txt

paul@laika:~/perms$ ls -l permissions.txt

-rwxrwxrwx 1 paul paul 0 2007-02-07 22:34 permissions.txt

paul@laika:~/perms$ chmod 664 permissions.txt

paul@laika:~/perms$ ls -l permissions.txt

-rw-rw-r-- 1 paul paul 0 2007-02-07 22:34 permissions.txt

paul@laika:~/perms$ chmod 750 permissions.txt

paul@laika:~/perms$ ls -l permissions.txt

-rwxr-x--- 1 paul paul 0 2007-02-07 22:34 permissions.txt

(Source: Linux Fundamentals, Cobbaut, 220)