Accounts and groups

UID and GID, the seven fields of /etc/passwd, the role of /etc/shadow and /etc/group, primary and secondary groups, people accounts and service accounts, and the id, whoami and groups commands.

  • 27 cards
  • 3 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

A few cards from the deck

  • User account: what is it?

    Show the answer

    An identity under which processes run and to which files belong, with a name, a number, a primary group, a home directory and a shell.

    The kernel only knows numbers: the login name is a convenience for humans, which the account files map to the UID.

  • In this /etc/passwd line, what are tom's UID and shell?

    ```text
    tom:x:1002:1002:Tom Durand:/home/tom:/bin/zsh
    `

    • 1002 and /bin/zsh
    • x and /bin/zsh
    • 1002 and /home/tom
    • Tom Durand and /home/tom
    Show the answer

    1002 and /bin/zsh

    The fields are: name (tom), x, UID (1002), GID (1002), comment, home directory (/home/tom) and shell (/bin/zsh). The UID is the third, the shell is the last.

  • A line of /etc/passwd has … fields separated by …: name, x, UID, GID, comment, home directory and shell.

    Show the answer

    A line of /etc/passwd has seven fields separated by colons: name, x, UID, GID, comment, home directory and shell.

    That layout is what cut -d: -f1 exploits to list login names. The sixth field is the home directory, the seventh the shell.

  • UID: what is it?

    Show the answer

    The integer by which the kernel identifies an account; the administrator account's is 0.

    Permissions are checked on the UID, not the name: two accounts with the same UID are the same account to the kernel. Ordinary accounts usually start at 1000.

  • Which accounts in this /etc/passwd excerpt can open an interactive session?

    ```text
    root:x:0:0:root:/root:/bin/bash
    daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
    www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
    lea:x:1000:1000:Léa Martin:/home/lea:/bin/bash
    `

    • daemon and www-data
    • root and lea
    • root, daemon and lea
    • All four: the shell does not prevent logging in
    Show the answer

    root and lea

    A nologin shell refuses the session as soon as you log in: it is the mark of service accounts. Only root and lea have a real shell, /bin/bash.