CertGrid CertGrid
Concepts·LPIC-1

Targets, runlevels, and what the kernel found

Objective 101.3 is runlevels and boot targets, and on a current machine the honest answer is that runlevels are a compatibility layer over systemd targets. This guide shows the target the machine boots to - and the surprise that the file supposedly defining it does not exist - then uses /proc and /sys to inventory the hardware without installing anything.

101: System Architecture Guide 5 of 33 Beginner

One Debian-family host. Every command reads firmware, kernel or systemd state - nothing is configured, enabled or changed.
Server NameIP AddressOSRolesCPURAMHDD
LPIC1-A01192.168.0.76Ubuntu 26.04 LTSDebian-family host - dpkg and apt, which objective 102.4 names2 Core4 GB50 GB

This guide includes

Use this for the runlevels objective on a machine that no longer has them. This matters because the compatibility layer answers some of these questions and not others - and the file the objective describes is not there at all.

Before you start

  1. The default target, and the file that is not there

    get-default answers even with nothing configured.

    bash Example session
    systemctl get-default; echo "---"; ls -l /etc/systemd/system/default.targetgraphical.target---ls: cannot access '/etc/systemd/system/default.target': No such file or directory[exit 2]systemctl list-units --type=target --state=active --no-pager | head -6  UNIT                    LOAD   ACTIVE SUB    DESCRIPTION  basic.target            loaded active active Basic System  boot-complete.target    loaded active active Boot Completion Check  cryptsetup.target       loaded active active Local Encrypted Volumes  getty-pre.target        loaded active active Preparation for Logins  getty.target            loaded active active Login Prompts

    Expected resultgraphical.target - and then ls: cannot access '/etc/systemd/system/default.target': No such file or directory, followed by the targets currently active.

    Success conditionYou know where a default comes from when nobody has set one.

  2. Runlevels, and why the command is missing

    The compatibility layer, and its limits.

    zsh Example session
    systemctl list-dependencies multi-user.target --no-pager 2>/dev/null | head -6multi-user.target● ├─apport.service● ├─chrony.service● ├─console-setup.service● ├─cron.service● ├─dbus.servicerunlevel; who -r; echo "--- the old interface, still answered for compatibility"zsh:2: command not found: runlevel--- the old interface, still answered for compatibility

    Expected resultThe services multi-user.target pulls in - chrony, cron, dbus - and then zsh: command not found: runlevel.

    Success conditionYou can answer a runlevel question on a machine that has no runlevels.

  3. Hardware, from files that are not on a disk

    /proc and /sys are generated when you read them.

    bash Example session
    lscpu | grep -E '^(Architecture|CPU\(s\)|Model name|Hypervisor vendor|Virtualization)'Architecture:                            x86_64CPU(s):                                  2Model name:                              Intel(R) Core(TM) i9-14900KHypervisor vendor:                       MicrosoftVirtualization type:                     fulllsblk -d -o NAME,SIZE,ROTA,TYPE | head -6; echo "--- ROTA 1 = spinning, 0 = solid state"NAME  SIZE ROTA TYPEfd0     4K    1 disksda     5G    1 disksdb     5G    1 disksdc     5G    1 disksdd     5G    1 disk--- ROTA 1 = spinning, 0 = solid statedf -h /proc /sys | tail -2; echo "--- size 0: they are generated on read"proc               0     0     0    - /procsysfs              0     0     0    - /sys--- size 0: they are generated on read

    Expected resultx86-64, 2 CPUs, an i9-14900K under a Microsoft hypervisor; the disks with ROTA 1; and /proc and /sys reporting size 0.

    Success conditionYou can inventory a machine without installing a single tool.

Troubleshooting

Official sources