Chapter 9: Services and the boot process

systemd and boot cheat sheet

The chapter on one page: what to remember, the commands to have at your fingertips, and flashcards for quick revision.

The chapter in eight sentences

Cheat sheet

Services

CommandDoes
`systemctl startstop
`systemctl enabledisable [--now] NAME`
`systemctl maskunmask NAME`
systemctl status NAMEState and recent log
`systemctl is-activeis-enabled NAME`
systemctl list-units --type=serviceWhat is loaded
systemctl list-unit-filesWhat is installed
systemctl --failedFailed units
journalctl -u NAMEThe service's log

Unit files

ItemDetail
Your units/etc/systemd/system/NAME.service
Packaged units/usr/lib/systemd/system/ (do not edit)
Drop-in/etc/systemd/system/NAME.service.d/*.conf or systemctl edit NAME
Show what appliessystemctl cat NAME
After any changesystemctl daemon-reload
Check the filesystemd-analyze verify FILE
[Service]ExecStart=, Restart=, User=, Environment=
[Install]WantedBy=multi-user.target
Status 203/EXECProgram not found or not executable

Boot and recovery

Command / keyDoes
systemctl get-default, set-default TShow / set the boot target
systemctl isolate TSwitch the running system
systemd-analyze, blame, critical-chainBoot timing
cat /proc/cmdlineArguments of the running kernel
grubby --update-kernel=ALL --args=XAdd a kernel argument (--remove-args removes)
GRUB: e, then Ctrl+XEdit one boot
rd.breakEarly shell for a root-password reset
findmnt --verify, mount -aTest /etc/fstab
nofailOptional file system

Flashcards

Start, stop, restart and reload a service?
systemctl start | stop | restart | reload NAME
Boot policy versus current state?
enable/disable change boot; start/stop change now. is-enabled and is-active ask.
Make a service start now and at boot?
systemctl enable --now NAME
Forbid a service completely?
systemctl mask NAME (undo with unmask)
See a service in detail, and its log?
systemctl status NAME · journalctl -u NAME
List failed units?
systemctl --failed
Where are your unit files, and what after editing?
/etc/systemd/system/ · systemctl daemon-reload
Three sections of a service unit?
[Unit] description and ordering · [Service] what to run · [Install] what enable does
Show and change the default target?
systemctl get-default · systemctl set-default multi-user.target
Boot order in six words?
Firmware, GRUB, kernel, initramfs, systemd, target.
Add a kernel argument permanently, and for one boot?
grubby --update-kernel=ALL --args=... · press e in GRUB
Reset root password with console access?
rd.break, remount /sysroot rw, chroot, passwd root, touch /.autorelabel, exit twice.