group team · 1003$ ls -l notes.txt-rw-r----- 1 alice team …$ chmod g+w notes.txt$ ls -l notes.txt-rw-rw---- 1 alice team …UID 1000aliceUID 1001bobUID 1002carolUID 0rootLinux kernelgroup r-- · read allowedothers --- · Permission deniedowner alice · mode now 660group rw- · write allowedUID 0 · bits not checkednotes.txtalice · teamrwx010101rwx010101rwx010101ownerrw-groupr--others---1001 read1002 readchmod g+w1001 write0 read
Back: alice's terminal, the group team (alice, bob), carol and root. Middle: the Linux kernelFront: notes.txt and its nine mode bits, r w x for owner, group and othersTokens: a process's request (its UID and read or write) on its way to the kernelUser space at the back: alice's terminal, the group team (alice and bob), carol and root. The Linux kernel in the middle checks every request. In front, the file notes.txt and its mode: three sets of r, w, x lamps for the owner, the group and others. The kernel tries the owner set, then the group set, then others, and uses the first that matches: bob gets the group bits, carol the others bits. chmod g+w turns on one lamp; root skips the check. The users, their numbers and the group team are an example. On Debian, Ubuntu and Fedora the first regular user gets UID 1000 and, by default, a personal group of the same name. The ls -l lines on the card are cut after the group; the full line also shows the size, date and name.

Users and groups

  1. Linux knows each user by a number, the user ID (UID). The file /etc/passwd lists them: here alice is 1000, bob 1001 and carol 1002. Regular users start at 1000. root, UID 0, is the administrator.

A file's mode

The kernel checks

Changing the rules

What happens

;; step 1/10 · users
/etc/passwd   one line per user
  name:password:UID:GID:comment:home:shell
  root:x:0:0:root:/root:/bin/bash
  alice:x:1000:1000::/home/alice:/bin/bash
  bob:x:1001:1001::/home/bob:/bin/bash
  carol:x:1002:1002::/home/carol:/bin/bash
x   the password itself is kept in /etc/shadow

The users, their numbers and the group team are an example. On Debian, Ubuntu and Fedora the first regular user gets UID 1000 and, by default, a personal group of the same name. The ls -l lines on the card are cut after the group; the full line also shows the size, date and name. Strictly, the kernel compares the file with the process's filesystem user and group IDs, which normally equal its effective IDs. The order is fixed: owner, then group, then others; once one matches, the others are not looked at, so an owner with fewer rights than the group is still held to the owner bits.