systemd general commands

Commands What it does
systemctl –failed List failed systemd units
systemctl –failes –all List all failed services in systemd
systemctl –user -t target See what systemd targets are running
systemctl –user list-dependencies default.target See if the default target wants a user service
systemctl enable multi-user.target –force Make multi-user target available in a normally graphical OS
systemctl get-default Get current runlevel
systemctl isolate graphical.target Switch to gui mode, runlevel 5
systemctl isolate multi-user.target Switch to server mode (runlevel 3), no gui
bluetooth.service Show dependencies systemctl list-dependencies
systemctl list-timers -a List all timers
systemctl list-unit-files Shows all services, sockets, timers, and sockets
systemctl list-unit-files –type=service List systemd service files
systemctl list-units Show running units
systemctl list-units –type=service –state=active systemd services currently active
systemctl list-units –type=service –state=running systemd services currently active and running
systemctl set-default graphical.target Change the default systemd startup mode to a gui
systemctl set-default multi-user.target Change the default systemd startup mode to a terminal only
systemctl suspend Suspend computer
systemctl hibernate Hibernate computer
systemctl reboot –boot-loader-entry=Pop_OS-oldkern.conf Boots to the oldkern, can be changed to match another entry like Windows or Recovery
systemctl reboot –boot-loader-entry=help List all boot entries for systemd-boot
systemctl reboot –firmware-setup Restarts the system into BIOS
systemctl restart name.service Restart a service like bluetooth.service or apache2.service
systemctl status name.service See what is going on with a service
systemctl status –no-pager Show tree of processes
systemd-analyze plot > boot_analysis.svg Create a graphic of the boot time and process
systemd-resolve –status List network info like DNS Servers

systemd v251+ (in Ubuntu 22.10+)

Commands What it does
bootctl set-timeout TIMEOUT Sets the boot loader menu timeout in seconds
bootctl set-timeout-oneshot TIMEOUT Set the boot loader menu timeout only for the next boot

systemd v249 (Pop!_OS 22.04/Ubuntu 22.04)

Commands What it does
bootctl set-default ID Sets the new boot device/target
bootctl set-oneshot ID Sets the new boot device/target for only the next boot

systemd-boot

Systemd-boot started with just support for UEFI which means the code base is much smaller when compared to GRUB which has a ton of code to work with different types of drives that have been released in the last decade. Pop!_OS has been using it since the 18.04 LTS release and I have been using it as my go to boot manager ever since.

efibootmgr

Commands What it does
efibootmgr List boot entries
sudo efibootmgr -n #### Sets that boot entry for the next boot only
sudo efibootmgr -N #### Deletes the boot next
sudo efibootmgr –timeout=5 Add a 5 second timeout to boot
sudo efibootmgr -b #### -B Remove boot entry matching the ####

This command allows us to edit the EFI variables though EFISTUB, the Arch Wiki has a really good selection about using efibootmgr. Here is my output as an example since I will be using the output in the next section:

BootNext: 0001
BootCurrent: 0001
Timeout: 2 seconds
BootOrder: 0001,000A,0002,0006,0000
Boot0000* UiApp
Boot0001* Pop!_OS 22.04 LTS
Boot0002* WDC WDS120G2G0B-00EPW0 
Boot0006* WDC WDS100T2B0C-00PXH0 
Boot000A* Linux Boot Manager

Now you may not have the "BootNext:" option if you haven't used efibootmgr before.

Desktop files

You can make your own desktop file and for system-wide you would put them in /usr/share/applications/ but if you want them just for your user you can use ~/.local/share/applications/. We can make .desktop files for these boot entries to set them as the next boot target but once you reboot again it reverts to using "BootOrder" order instead.

This is my file for booting Arch on the next reboot:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Exec=sh -c "pkexec efibootmgr -n 000A"
Name=Boot to Arch
Icon=/home/aaronh/Documents/archlinux-icon.svg

and this is my file for booting Pop!_OS on the next boot:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Exec=sh -c "pkexec efibootmgr -n 0001"
Name=Boot to Pop!_OS
Icon=/home/aaronh/Documents/pop_icon.svg