rwx permissions and chmod

The nine rwx bits of the owner, the group and others, what they mean on a file and on a directory, symbolic and octal notation, chmod, and the setuid, setgid and sticky bits.

  • 26 cards
  • 5 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Questions
  3. Sort and link
  4. The numbers
  5. Scenarios

A few cards from the deck

  • Unix permissions: what is it?

    Show the answer

    Nine bits split into three triplets (owner, group, others) that say who may read (r), write (w) and execute (x) a file.

    The system picks a single triplet: owner if you are the owner, otherwise group if you belong to it, otherwise others. An owner with no right is not rescued by the group triplet.

  • Which line does ls -l show after these commands?

    ```bash
    touch f
    chmod 754 f
    ls -l f
    `

    • -rwxr-xr--
    • -rwxrwxr--
    • -rwxr--r-x
    • -r-xr-xrw-
    Show the answer

    -rwxr-xr--

    7 = 4+2+1 gives the owner rwx, 5 = 4+1 gives the group r-x, 4 gives others r--. -rwxr--r-x would be 745: the last two digits swapped.

  • In octal notation, r is …, w is … and x is …: each digit is the sum of the triplet's permissions.

    Show the answer

    In octal notation, r is 4, w is 2 and x is 1: each digit is the sum of the triplet's permissions.

    They are the powers of 2: one bit per permission. To read 6, find the sum: 4 + 2, so rw-.

  • chmod: what is it?

    Show the answer

    The command that changes a file's permissions, in symbolic notation (u, g, o, a with +, - or =) or in octal.

    chmod u+x script.sh adds x for the owner and leaves the rest alone; chmod 755 script.sh sets all nine bits at once. Only the file's owner and root may change its permissions.