394. Users and groups
This page is about the accounts on a KDOS machine: the one that ships, how to add, change and remove others, which groups an account needs for the hardware, and which account the machine logs in by itself. What the wheel group grants, and why each hardware group exists, is in the KDOS book’s Users and groups section, which this page does not repeat.
Installation
| What | Port |
|---|---|
useradd, usermod, userdel, groupadd, gpasswd, passwd, chsh, su, newuidmap, newgidmap |
shadow |
agetty, which runs the login prompt on each console |
util-linux |
login, built against PAM |
util-linux-login |
| The Users page of System Settings, and the account pictures on the greeter | plasma-desktop, accountsservice |
| The automatic login, on the Login Screen (SDDM) page | sddm-kcm |
unix_chkpwd, the lock screen’s password check for a process that is not root |
pam |
shadow is built without PAM, so su and passwd read /etc/shadow themselves; the port’s page says why. Every login, the greeter’s, the consoles’ and the lock screen’s, goes through PAM; see sudo, PAM and polkit. The account files themselves are not from a port: /etc/passwd, /etc/group, /etc/shadow, /etc/subuid, /etc/subgid and /etc/skel come from the tree’s fs/ overlay, and ports that need a service account add it from their postinstall.sh (System accounts).
An account’s runtime directory, /run/user/<uid>, is made by turnstile’s PAM module at the account’s first login and removed after its last; see Session and environment.
On the live medium the desktop account is kdos with the password kdos, and root has the same password. The installer asks for the account’s name and password, renames kdos to the name given, and locks root unless told otherwise; see 6. Accounts.
Configuration
/etc/passwd, from fs/etc/passwd. Every account but root and kdos is a service account with /sbin/nologin:
root:x:0:0:root:/root:/bin/bash
dhcpcd:x:999:999:dhcpcd:/var/lib/dhcpcd:/sbin/nologin
messagebus:x:997:997:messagebus:/:/sbin/nologin
sshd:x:996:996:sshd:/var/lib/sshd:/sbin/nologin
tss:x:993:993:tss:/:/sbin/nologin
lp:x:10:10:lp:/:/sbin/nologin
utmp:x:14:14:utmp:/run/utmps:/sbin/nologin
sddm:x:64:64:SDDM Greeter Account:/var/lib/sddm:/sbin/nologin
nobody:x:99:99:nobody:/:/sbin/nologin
kdos:x:1000:1000:KDOS User:/home/kdos:/bin/bash
/etc/group, from fs/etc/group. The last field lists the members; kdos is in wheel and the hardware groups. sambashare (gid 65) is the group whose members may publish a folder as a share; see File sharing:
root:x:0:
bin:x:1:
sys:x:2:
kmem:x:3:
tty:x:5:kdos
tape:x:6:
daemon:x:7:
floppy:x:8:
disk:x:9:
lp:x:10:
dialout:x:11:kdos
audio:x:12:kdos
video:x:13:kdos
utmp:x:14:
at:x:15:
cdrom:x:16:kdos
man:x:17:
dial:x:18:
games:x:20:
render:x:28:kdos
input:x:29:kdos
sgx:x:30:
kvm:x:32:kdos
lock:x:54:
sddm:x:64:
sambashare:x:65:
nobody:x:99:
users:x:100:kdos
network:x:101:
tss:x:993:
lpadmin:x:995:kdos
sshd:x:996:
messagebus:x:997:
wheel:x:998:kdos
dhcpcd:x:999:
kdos:x:1000:
/etc/shadow, from fs/etc/shadow, holds the password hashes: the live password of root and kdos, and ! (no password, no login) for every service account. Git cannot record its mode, so the build sets it to 600; see The mode of /etc/shadow.
/etc/subuid and /etc/subgid, from fs/etc/subuid and fs/etc/subgid, give each account a range of user and group ids for rootless containers, which every boxed application runs in. The two files are the same:
kdos:100000:65536
root:200000:65536
/etc/shells, from fs/etc/shells, lists the shells chsh accepts:
/bin/sh
/bin/bash
/usr/bin/sh
/usr/bin/bash
/bin/zsh
/usr/bin/zsh
/etc/login.defs is shadow’s own file. It sets the id ranges useradd picks from (ordinary ids from 1000, subordinate ids from 100000), and the hash passwd writes: its ENCRYPT_METHOD line is commented out, so passwords are hashed with SHA-512, shadow’s default. The port comments out its MAIL_DIR line, so no account keeps a mailbox. It sets HOME_MODE 0700, so the home useradd -m creates is readable by its owner alone, as the installer makes the first account’s; UMASK stays 022. See the shadow page.
/etc/default/useradd, from fs/etc/default/useradd, holds the defaults useradd gives a new account. It sets two: GROUPS=audio, so every ordinary account joins the group that carries PipeWire’s real-time limits (Audio), whichever tool makes it — System Settings’ Users page through AccountsService, Plasma Setup, or useradd by hand — and CREATE_MAIL_SPOOL=no. useradd -G replaces the GROUPS= list rather than adding to it, so a list given by hand names audio again, and a system account (useradd -r) never gets it; AccountsService is patched to add an administrator’s wheel after useradd for the same reason (see accountsservice). Every other key keeps useradd’s compiled default, and useradd -D prints them all:
# useradd's defaults for a new account. `useradd -D` prints every key with
# its value, this file's or the compiled one. `useradd -D -s SHELL` and its
# other flags write every key into this file, keeping these comments.
# Every ordinary account joins audio, whose members get PipeWire's real-time
# limits (/etc/security/limits.d/25-pw-rlimits.conf); without them sound
# drops out under load. This is what puts accounts made by System Settings,
# AccountsService and Plasma Setup in audio, as the installer's account is.
# useradd -G replaces this list instead of adding to it, and a system account
# (useradd -r) never gets it.
GROUPS=audio
# No mailbox: login.defs names no MAIL_DIR, nothing delivers local mail and the
# image has no spool directory, so this says what useradd does.
CREATE_MAIL_SPOOL=no
/etc/skel, from fs/etc/skel, is copied into each new home by useradd -m: the shell profiles, the pinned applications and the terminal programs’ starting configuration. Plasma’s own settings are not there: a new account reads the KDOS defaults in /usr/share/kdos/xdg until it changes something.
/etc/sddm.conf.d/kde_settings.conf names the account the machine logs in by itself, if any; see Login and autologin.
Usage
Changing a password
- Your own:
passwd. - Another account’s, as an administrator:
sudo passwd <user>.
Change the live password before anything else; sudo kdos doctor warns while the kdos account still has it.
Adding a desktop user
Create the account with a home, the desktop’s groups and bash. For an administrator, as the shipped account is:
sudo useradd -m -s /bin/bash \ -G wheel,users,audio,video,render,input,kvm,cdrom,dialout,lpadmin,tty aliceFor an account that runs the desktop but does not administer the machine, leave
wheelout of the list. No group is needed for the desktop itself: elogind hands the display and the input devices to whoever’s session is active, and polkit lets that person suspend, power off and mount removable media. System Settings → Users → Add New makes an account inaudioalone, pluswheelfor the account type Administrator; add the hardware groups to it afterwards withsudo usermod -a -G <groups> alice.Give it a password:
sudo passwd aliceCheck that
useraddgave it a range of subordinate ids, which boxed applications need:grep alice /etc/subuid /etc/subgidThe first account added after
kdosgetsalice:265536:65536in both, the range afterroot’s. If either file has no line for it, see Troubleshooting.Make the empty directories the desktop’s programs expect.
useradd -mcopies/etc/skel, which carries onlyDesktopof these; the image build makes the rest in thekdoshome alone. The mail programs need~/Mail, and the calendar and address book need their stores under~/.local/share; none of them creates its directory:sudo -u alice mkdir -p /home/alice/{Desktop,Downloads,Documents,Music,Videos,Public,Templates,Projects} \ /home/alice/{Mail,Pictures/Screenshots,.local/bin,.local/share/applications} \ /home/alice/.local/share/{calendars,addressbooks}/personalLog in as the account at the greeter, which lists it at once. Its runtime directory and services start with that first login.
Adding an account to a group
sudo usermod -aG dialout alice
-a adds to the account’s groups; without it, -G replaces them. The change applies from the account’s next login: id alice shows it at once, while id in a session started before it does not.
To take an account out of a group, here to stop it administering the machine:
sudo gpasswd -d alice wheel
Choosing the account the machine logs in by itself
System Settings → Login Screen (SDDM) → Behavior → Automatically log in, with the account and Plasma (Wayland); see Turning autologin on or off.
Locking and removing an account
Lock it, so no password opens it, and unlock it again:
sudo usermod -L alice sudo usermod -U aliceRemove it with its home directory. If the automatic login names it, turn that off first. System Settings → Users → Delete User does the same, and asks whether to keep the files. End its processes before
userdel: its user services,ssh-agentamong them, run until its last logout, anduserdelrefuses an account with a running process (user alice is currently used by process <pid>, exit 8):sudo pkill -u alice sudo userdel -r aliceCheck that no subordinate id range is left for it with
grep alice /etc/subuid /etc/subgid.
The root account
- Lock it:
sudo passwd -l root. The installer does this by default. - Give it a password:
sudo passwd root.
Keep at least one account in wheel while root is locked, or nobody can administer the machine.
Changing a login shell
chsh -s /bin/zsh
The shell must be listed in /etc/shells and installed. The session wrapper starts Plasma from a login shell of whichever of bash or zsh it is, so either one’s profile reaches the desktop.
On the live medium
Every change on this page is to /etc or /home, and on the live medium both are in RAM and start again from the image at every boot. A persistence store keeps them (kdos persist).
Tips
tty2is a plain login prompt for any account, whatever the automatic login says: the way in when the desktop account’s session will not start.Ctrl+Alt+F2reaches it from the desktop.newgrp dialoutstarts a shell with a group just added, without logging out.- The ranges in
/etc/subuidand/etc/subgidmust not overlap. Each line is the account, the first id and the number of ids; the shipped ranges are in the file shown under Configuration.
Troubleshooting
A new account’s desktop does not start, or its programs complain about XDG_RUNTIME_DIR. Its runtime directory is missing, which means turnstile did not run for its login:
ls -ld /run/user/$(id -u alice)
service status turnstiled
Boxed applications do not start for one account. kdos doctor, run as that account, warns no /etc/subuid entry in its Containers section. Give it a range that overlaps no other line of /etc/subuid or /etc/subgid: read both files, and start past the end (first id plus count) of the highest range in either. With only the shipped lines, that is 265536:
cat /etc/subuid /etc/subgid
sudo usermod --add-subuids 265536-331071 --add-subgids 265536-331071 alice
The lock screen refuses the right password. unix_chkpwd has lost its setuid bit, or the account is locked; see Screen lock.
A device answers Permission denied. The account lacks the group that owns it. ls -l on the device node shows the group. For serial adapters, cameras and instruments, kdos doctor, run as that account, lists the nodes it cannot open with their groups in its Hardware section. Add the group as above.
userdel prints user alice is currently used by process <pid> and exits 8. A process of the account is still running, such as a user service of a login that has not ended, a shell or a lingering account’s container, and userdel removes nothing. End them and try again:
sudo pkill -u alice
sudo userdel -r alice
sudo says the account is not in the sudoers file. It is not in wheel; see sudo, PAM and polkit.
The greeter asks for a password on an installed machine. That is the installed default. Set the automatic login if the machine should log in by itself.
Known gaps
- Security: the live medium’s shared password, its automatic logins, and
wheelbeing effectively root
See also
- Users and groups: what each group grants
- System accounts: the service accounts and how ports add them
- 6. Accounts: what the installer asks and rewrites
- sudo, PAM and polkit: what
wheelmembership lets an account do - Login and autologin: the greeter and the automatic login
- Screen lock: the lock screen and its PAM stack
- Live persistence: keeping accounts on the live medium