Skip to main content

05. Users and Permissions

You will learn​

  • what a user is for the kernel: just a number, the UID, that labels every process, and how UIDs are split between root, system users and regular users
  • how the local users database (/etc/passwd) works and how programs turn a UID into a name through the C library (getpwuid(), getpwnam()), and why scripts should use getent instead of reading the file with grep or cut
  • how passwords are stored locally: only a salted hash, kept in /etc/shadow, which only root can read
  • what groups are (/etc/group) and how they give rights to several users at once
  • what happens when you log in (getty, login), how a process gets the label of a user and how /etc/nsswitch.conf tells the C library where the users are: local files or a network server
  • who the root user is: UID 0, for which the kernel skips most checks, the name does not matter
  • how to become root: why sudo (your password, /etc/sudoers, a log) is better than su, and why sudo echo ... >> file does not work
  • how file permissions work: owner, group and others, r, w, x for files and for directories (a directory is a list of names), which single set applies, and how to change them with chmod, umask, chown and chgrp
  • what the special permissions are, setuid, setgid and the sticky bit, and why you should not set +s on your own programs
  • why you should not trust the prompt to tell you who you are and ask the kernel with whoami and id

Slides​

Download Slides