Get full Access to Website Content, WebShark packet capture tool and Proximity Download. Purchase
⛶ Night Mode

Linux System Startup

Booting Process

When you turn on or restart a computer, the Linux booting process begins. The key steps in this process are:

  • BIOS/UEFI: The computer’s firmware (BIOS or UEFI) runs a power-on self-test (POST) and initializes hardware components.
  • Bootloader: The bootloader (commonly GRUB) is loaded, presenting a menu if multiple operating systems are installed.
  • Kernel Loading: The bootloader loads the Linux kernel (vmlinuz) into memory.
01. BIOS / UEFI

BIOS and UEFI are firmware interfaces that computers use to boot up the operating system (OS).

02. BOOT LOADER

The boot loader is a small program that loads the operating system

03. KERNEL

After going through BIOS or UEFI, POST, and using a boot loader to initiate the kernel.

04. SYSTEMD

The parent of all Linux processes is Systemd.

05. RUN LEVELS

In Linux, the run level stands for the current state of the operating system.

01. BIOS / UEFI

First, the BIOS (Basic Input/Output System) or UEFI (Unified Extensible Firmware Interface) program kicks in once the system powers up. Usually, the BIOS contains all the code to gain initial access to the main machine devices:

  • keyboard
  • display screen
  • disk drives
  • serial communications

However, most of these devices will have dedicated device drivers taking over once the system boots fully.

BIOS and UEFI are firmware interfaces that computers use to boot up the operating system (OS). Yet, the two programs differ in how they store metadata on and about the drive:

  • BIOS uses the Master Boot Record (MBR)
  • UEFI uses the GUID Partition Table (GPT)

Next, the BIOS or UEFI runs the power-on self-test (POST). The POST does a series of tasks:

  • verify the hardware components and peripherals
  • carry out tests to ensure that the computer is in proper working condition

Further, if this test finds any error, it commonly shows an error message on the screen. In case the test fails to detect the RAM, POST triggers a beeping sound.

Finally, if the system passes the POST, it signals the start-up process to the next stage.

Here are some commands to check whether your Linux Debian system is running in BIOS or UEFI mode, you can use various methods, including checking the partition scheme, examining system logs, or using command-line utilities.

root@ipxpy-debian-server:~$ lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT
NAME FSTYPE SIZE MOUNTPOINT
sda 10G
├─sda1 ext4 9.9G /
├─sda14 3M
└─sda15 vfat 124M /boot/efi
root@ipxpy-debian-server:~$
root@ipxpy-debian-server:~$ lsblk

NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda       8:0    0   10G  0 disk
├─sda1    8:1    0  9.9G  0 part /
├─sda14   8:14   0    3M  0 part
└─sda15   8:15   0  124M  0 part /boot/efi
root@ipxpy-debian-server:~$ lsblk -t
NAME    ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED RQ-SIZE  RA WSAME
sda             0   4096      0    4096     512    0 none     8192 128    4G
├─sda1          0   4096      0    4096     512    0 none     8192 128    4G
├─sda14         0   4096      0    4096     512    0 none     8192 128    4G
└─sda15         0   4096      0    4096     512    0 none     8192 128    4G
root@ipxpy-debian-server:~$

Look for a partition labeled as “EFI System Partition” (ESP). If you see this partition, your system is running in UEFI mode. If not, it’s likely running in BIOS mode.

root@ipxpy-debian-server:~$ lsblk --help

Usage:
 lsblk [options] [<device> ...]

List information about block devices.

Options:
 -D, --discard        print discard capabilities
 -E, --dedup <column> de-duplicate output by <column>
 -I, --include <list> show only devices with specified major numbers
 -J, --json           use JSON output format
 -O, --output-all     output all columns
 -P, --pairs          use key="value" output format
 -S, --scsi           output info about SCSI devices
 -T, --tree[=<column>] use tree format output
 -a, --all            print all devices
 -b, --bytes          print SIZE in bytes rather than in human readable format
 -d, --nodeps         don't print slaves or holders
 -e, --exclude <list> exclude devices by major number (default: RAM disks)
 -f, --fs             output info about filesystems
 -i, --ascii          use ascii characters only
 -l, --list           use list format output
 -M, --merge          group parents of sub-trees (usable for RAIDs, Multi-path)
 -m, --perms          output info about permissions
 -n, --noheadings     don't print headings
 -o, --output <list>  output columns
 -p, --paths          print complete device path
 -r, --raw            use raw output format
 -s, --inverse        inverse dependencies
 -t, --topology       output info about topology
 -z, --zoned          print zone model
 -x, --sort <column>  sort output by <column>
     --sysroot <dir>  use specified directory as system root

 -h, --help           display this help
 -V, --version        display version

Available output columns:
        NAME  device name
       KNAME  internal kernel device name
        PATH  path to the device node
     MAJ:MIN  major:minor device number
     FSAVAIL  filesystem size available
      FSSIZE  filesystem size
      FSTYPE  filesystem type
      FSUSED  filesystem size used
      FSUSE%  filesystem use percentage
       FSVER  filesystem version
  MOUNTPOINT  where the device is mounted
       LABEL  filesystem LABEL
        UUID  filesystem UUID
      PTUUID  partition table identifier (usually UUID)
      PTTYPE  partition table type
    PARTTYPE  partition type code or UUID
 PARTTYPENAME  partition type name
   PARTLABEL  partition LABEL
    PARTUUID  partition UUID
   PARTFLAGS  partition flags
          RA  read-ahead of the device
          RO  read-only device
          RM  removable device
     HOTPLUG  removable or hotplug device (usb, pcmcia, ...)
       MODEL  device identifier
      SERIAL  disk serial number
        SIZE  size of the device
       STATE  state of the device
       OWNER  user name
       GROUP  group name
        MODE  device node permissions
   ALIGNMENT  alignment offset
      MIN-IO  minimum I/O size
      OPT-IO  optimal I/O size
     PHY-SEC  physical sector size
     LOG-SEC  logical sector size
        ROTA  rotational device
       SCHED  I/O scheduler name
     RQ-SIZE  request queue size
        TYPE  device type
    DISC-ALN  discard alignment offset
   DISC-GRAN  discard granularity
    DISC-MAX  discard max bytes
   DISC-ZERO  discard zeroes data
       WSAME  write same max bytes
         WWN  unique storage identifier
        RAND  adds randomness
      PKNAME  internal parent kernel device name
        HCTL  Host:Channel:Target:Lun for SCSI
        TRAN  device transport type
  SUBSYSTEMS  de-duplicated chain of subsystems
         REV  device revision
      VENDOR  device vendor
       ZONED  zone model
         DAX  dax-capable device

For more details see lsblk(8).
root@ipxpy-debian-server:~$
root@ipxpy-debian-server:~$ ls -lhi /sys/firmware/efi
total 0
3124 -r--r--r-- 1 root root 4.0K Sep 18 16:54 config_table
1179 drwxr-xr-x 2 root root    0 Sep 18 10:51 efivars
3121 -r--r--r-- 1 root root 4.0K Sep 18 16:54 fw_platform_size
3122 -r--r--r-- 1 root root 4.0K Sep 18 16:54 fw_vendor
3123 -r--r--r-- 1 root root 4.0K Sep 18 16:54 runtime
3125 drwxr-xr-x 6 root root    0 Sep 18 16:54 runtime-map
3120 -r-------- 1 root root 4.0K Sep 18 16:54 systab
root@ipxpy-debian-server:~$

If this directory exists, your system is running in UEFI mode. If the directory is not found, your system is likely running in BIOS mode.

02. Boot Loader

The boot loader is a small program that loads the operating system. The main job of the boot loader is to perform three actions with the kernel: locate on the disk, insert into memory, and execute with the supplied options.

The following are some of the available boot loaders for a Linux system:

  • LILO
  • SYSILINUX
  • GRUB2

Above are some fundamental aspects of Linux and its system startup process. The specific commands and procedures may vary slightly depending on the Linux distribution you’re using, but these principles apply broadly to most Linux systems. Learning these basics is essential for effective Linux administration and usage.

To check which boot loader is currently being used on your Debian Linux system, you can use various commands and methods. Here are some common ways to do it:

You can check the default boot loader configuration file to see which one is set as the default. Debian uses GRUB (Grand Unified Boot Loader) as its default boot loader. To check the default boot loader configuration:

root@ipxpy-debian-server:~$ cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200 earlyprintk=ttyS0,115200 consoleblank=0"
GRUB_TERMINAL="console serial"
GRUB_SERIAL_COMMAND="serial --speed=115200"
root@ipxpy-debian-server:~$

This command will list all packages related to GRUB. You can replace “grub” with “syslinux,” “efibootmgr,” or other boot loader names to check for their presence.

root@ipxpy-debian-server:~$ dpkg -l | grep grub
ii  grub-cloud-amd64                      0.0.5                          amd64        GRand Unified Bootloader (cloud setup)
ii  grub-common                           2.06-3~deb11u5                 amd64        GRand Unified Bootloader (common files)
ii  grub-efi-amd64-bin                    2.06-3~deb11u5                 amd64        GRand Unified Bootloader, version 2 (EFI-AMD64 modules)
ii  grub-efi-amd64-signed                 1+2.06+3~deb11u5               amd64        GRand Unified Bootloader, version 2 (amd64 UEFI signed by Debian)
ii  grub-pc-bin                           2.06-3~deb11u5                 amd64        GRand Unified Bootloader, version 2 (PC/BIOS modules)
ii  grub2-common                          2.06-3~deb11u5                 amd64        GRand Unified Bootloader (common files for version 2)
root@ipxpy-debian-server:~$

This command will list all packages related to GRUB. You can replace “grub” with “syslinux,” “efibootmgr,” or other boot loader names to check for their presence.

root@ipxpy-debian-server:~$ dpkg -l | grep syslinux
root@ipxpy-debian-server:~$
root@ipxpy-debian-server:~$ dpkg -l | grep efibootmgr
ii  efibootmgr                            17-1                           amd64        Interact with the EFI Boot Manager
root@ipxpy-debian-server:~$

This command will list the available boot menu entries in the GRUB configuration file.

root@ipxpy-debian-server:~$ ls /boot/efi/EFI/debian/
BOOTX64.CSV  fbx64.efi  grub.cfg  grubx64.efi  mmx64.efi  shimx64.efi
root@ipxpy-debian-server:~$

02.1 LILO

Initially, LILO (Linux Loader) was one of the most widely used Linux boot loaders. However, it has lost favor because it has no support for multi-boot environments and for UEFI. Also, it has limited support for new filesystems. Officially, the developers of LILO halted its development and support in December 2015. Hence, the Linux Loader is old and mostly obsolete.

02.2 SYSLINUX

Equally, SYSLINUX is a boot loader for the Linux operating system, which runs on a FAT filesystem, typical for a Windows system. In short, its goal is to ease the process of installing Linux for the first time.

Further, SYSLINUX supports several major filesystems:

  • FAT
  • ext2
  • ext3
  • ext4

In addition, SYSLINUX can support Btrfs and XFS filesystems with some constraints.

02.3 GRUB2

Despite the many choices, almost all (non-embedded) modern Linux distributions use GRUB (GRand Unified Boot Loader) because it’s very feature-rich:

  • ability to boot multiple operating systems
  • boots both a graphical and a text-based interface
  • allows ease of use over a serial cable
  • strong command line interface for interactive configuration
  • network-based diskless booting

Presently, GRUB2 has replaced its past version (GRUB), which is now known as GRUB Legacy. Importantly, we can check for the GRUB version in our system using the following command:

Look for a partition labeled as “EFI System Partition” (ESP). If you see this partition, your system is running in UEFI mode. If not, it’s likely running in BIOS mode.

root@ipxpy-debian-server:~$ grub-install -V
grub-install (GRUB) 2.06-3~deb11u5
root@ipxpy-debian-server:~$ 

Now, let’s see what GRUB2 does in the boot process:

  1. takes over from BIOS or UEFI at boot time
  2. loads itself
  3. inserts the Linux kernel into memory
  4. turns over execution to the kernel

Notably, the GRUB configuration file is located at /boot/grub by default:

root@ipxpy-debian-server:~$ ls -l /boot/grub/
total 44
drwxr-xr-x 2 root root  4096 Aug 14 21:39 fonts
-rw-r--r-- 1 root root  7570 Sep 14 06:44 grub.cfg
-rw-r--r-- 1 root root  1024 Aug 14 21:39 grubenv
drwxr-xr-x 2 root root 12288 Aug 14 21:39 i386-pc
drwxr-xr-x 2 root root  4096 Aug 14 21:39 locale
drwxr-xr-x 2 root root 12288 Aug 14 21:39 x86_64-efi
root@ipxpy-debian-server:~$

Initially, GRUB Legacy had three stages in the boot process:

  1. Stage 1
  2. Stage 1.5
  3. Stage 2

However, with GRUB2, these stages don’t exist anymore. Instead, it contains various *.img files that serve similar functions.

At this point, GRUB2 inserts the kernel into memory and turns control of the system over to the kernel.

03. Kernel

After going through BIOS or UEFI, POST, and using a boot loader to initiate the kernel, the operating system now controls access to our computer resources.

Here, the Linux kernel follows a predefined procedure:

  1. decompress itself in place
  2. perform hardware checks
  3. gain access to vital peripheral hardware
  4. run the init process

Next, the init process continues the system startup by running init scripts for the parent process. Also, the init process inserts more kernel modules (like device drivers).

To check the kernel version in Debian Linux, you can use the uname command or inspect system files. Here are some common methods:

root@ipxpy:~# uname
Linux


root@ipxpy:~# uname -r
4.19.0-25-amd64


root@ipxpy:~# cat /proc/version
Linux version 4.19.0-25-amd64 (debian-kernel@lists.debian.org) (gcc version 8.3.0 (Debian 8.3.0-6)) #1 SMP Debian 4.19.289-2 (2023-08-08)


root@ipxpy:~# dpkg -l | grep linux-image
ii  linux-image-4.19.0-17-amd64   4.19.194-1                   amd64        Linux 4.19 for 64-bit PCs (signed)
ii  linux-image-4.19.0-25-amd64   4.19.289-2                   amd64        Linux 4.19 for 64-bit PCs (signed)
ii  linux-image-amd64             4.19+105+deb10u20            amd64        Linux for 64-bit PCs (meta-package)


root@ipxpy:~# ls /boot
config-4.19.0-17-amd64  grub                        initrd.img-4.19.0-25-amd64  System.map-4.19.0-25-amd64  vmlinuz-4.19.0-25-amd64
config-4.19.0-25-amd64  initrd.img-4.19.0-17-amd64  System.map-4.19.0-17-amd64  vmlinuz-4.19.0-17-amd64


root@ipxpy:~# uname -a
Linux ipxpy 4.19.0-25-amd64 #1 SMP Debian 4.19.289-2 (2023-08-08) x86_64 GNU/Linux

04. Systemd

To reiterate, the kernel initiates the init process, which starts the parent process. Here, the parent of all Linux processes is Systemd, which replaces the old SysVinit process. Following the booting steps, Systemd performs a range of tasks:

  • probe all remaining hardware
  • mount filesystems
  • initiate and terminate services
  • manage essential system processes like user login
  • run a desktop environment

Indeed, these and other tasks allow users to interact with the system. Lastly, Systemd uses the /etc/systemd/system/default.target file to decide the state or target the Linux system boots into.

SystemD, is a recent initialization system that aims to replace SysVInit. In fact, most Linux distributions such as Debian and Red Hat are already using SystemD as their init system out of the box. In contrast to SysVInit, SystemD continues to run as a daemon process after the initialization is completed. Additionally, they are also actively tracking the services through their cgroups. The systemctl command is the entry point for users to interact and configures the SystemD.

To check the status and information about systemd in Debian, you can use various commands and tools. Here are some common ways to check systemd:

You can check the installed systemd version using the systemctl command with the --version option:

root@ipxpy:~# systemctl --version
systemd 241 (241)
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid
root@ipxpy:~#

You can check the status of the systemd system and services using the following commands:

  • To check the overall status of the systemd system:
root@ipxpy:~# systemctl status
ipxpy
    State: running

     Jobs: 0 queued
   Failed: 0 units
    Since: Tue 2023-09-19 09:52:48 EDT; 1h 50min ago
   CGroup: /
           ├─user.slice
           │ └─user-0.slice
           │   ├─session-4.scope
           │   │ ├─602 sshd: root@pts/0
           │   │ ├─608 -bash
           │   │ ├─820 systemctl status
           │   │ └─821 pager
           │   ├─session-1.scope
           │   │ ├─409 /bin/login -p --
           │   │ ├─537 -bash
           │   │ └─574 nano sshd_conf
           │   └─user@0.service
           │     └─init.scope
           │       ├─532 /lib/systemd/systemd --user
           │       └─533 (sd-pam)
           ├─init.scope
           │ └─1 /sbin/init
           └─system.slice
             ├─apache2.service
             │ ├─458 /usr/sbin/apache2 -k start
             │ ├─461 /usr/sbin/apache2 -k start
             │ └─462 /usr/sbin/apache2 -k start
             ├─systemd-udevd.service
             │ └─282 /lib/systemd/systemd-udevd
             ├─cron.service
             │ └─378 /usr/sbin/cron -f
             ├─ifup@ens32.service
             │ └─364 /sbin/dhclient -4 -v -i -pf /run/dhclient.ens32.pid -lf /var/lib/dhcp/dhclient.ens32.leases -I -df /var/lib/dhcp/dhclient6.ens32.leases
             ├─systemd-journald.service
             │ └─260 /lib/systemd/systemd-journald
             ├─ssh.service
             │ └─581 /usr/sbin/sshd -D
             ├─rsyslog.service
             │ └─382 /usr/sbin/rsyslogd -n -iNONE
             ├─dbus.service
             │ └─387 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
             ├─systemd-timesyncd.service
             │ └─334 /lib/systemd/systemd-timesyncd
             └─systemd-logind.service
               └─380 /lib/systemd/systemd-logind
lines 3-46/46 (END)
root@ipxpy:~#

You can check the installed systemd version using the systemctl command with the --version option:

root@ipxpy:~# systemctl list-unit-files
UNIT FILE                                                                 STATE
proc-sys-fs-binfmt_misc.automount                                         static
-.mount                                                                   generated
dev-hugepages.mount                                                       static
dev-mqueue.mount                                                          static
media-cdrom0.mount                                                        generated
proc-sys-fs-binfmt_misc.mount                                             static
sys-fs-fuse-connections.mount                                             static
sys-kernel-config.mount                                                   static
sys-kernel-debug.mount                                                    static
systemd-ask-password-console.path                                         static
systemd-ask-password-wall.path                                            static
session-1.scope                                                           transient
session-4.scope                                                           transient
apache-htcacheclean.service                                               disabled
apache-htcacheclean@.service                                              disabled
apache2.service                                                           enabled
apache2@.service                                                          disabled
apparmor.service                                                          enabled
apt-daily-upgrade.service                                                 static
apt-daily.service                                                         static
autovt@.service                                                           enabled
bootlogd.service                                                          masked
bootlogs.service                                                          masked
bootmisc.service                                                          masked
checkfs.service                                                           masked
checkroot-bootclean.service                                               masked
checkroot.service                                                         masked
console-getty.service                                                     disabled
console-setup.service                                                     enabled
container-getty@.service                                                  static
cron.service                                                              enabled
cryptdisks-early.service                                                  masked
cryptdisks.service                                                        masked
dbus-org.freedesktop.hostname1.service                                    static
dbus-org.freedesktop.locale1.service                                      static
dbus-org.freedesktop.login1.service                                       static
dbus-org.freedesktop.timedate1.service                                    static
dbus-org.freedesktop.timesync1.service                                    enabled
dbus.service                                                              static
debug-shell.service                                                       disabled
emergency.service                                                         static
fstrim.service                                                            static
getty-static.service                                                      static
getty@.service                                                            enabled
halt.service                                                              masked
hostname.service                                                          masked
hwclock.service                                                           masked
ifup@.service                                                             static
ifupdown-pre.service                                                      static
ifupdown-wait-online.service                                              disabled
initrd-cleanup.service                                                    static
initrd-parse-etc.service                                                  static
initrd-switch-root.service                                                static
initrd-udevadm-cleanup-db.service                                         static
keyboard-setup.service                                                    enabled
killprocs.service                                                         masked
kmod-static-nodes.service                                                 static
kmod.service                                                              static
logrotate.service                                                         static
man-db.service                                                            static
module-init-tools.service                                                 static
motd.service                                                              masked
mountall-bootclean.service                                                masked
mountall.service                                                          masked
mountdevsubfs.service                                                     masked
mountkernfs.service                                                       masked
mountnfs-bootclean.service                                                masked
mountnfs.service                                                          masked
networking.service                                                        enabled
procps.service                                                            static
quotaon.service                                                           static
rc-local.service                                                          static
rc.local.service                                                          static
rc.service                                                                masked
rcS.service                                                               masked
reboot.service                                                            masked
rescue.service                                                            static
rmnologin.service                                                         masked
rsyslog.service                                                           enabled
sendsigs.service                                                          masked
serial-getty@.service                                                     disabled
single.service                                                            masked
ssh.service                                                               enabled
ssh@.service                                                              static
sshd.service                                                              enabled
stop-bootlogd-single.service                                              masked
stop-bootlogd.service                                                     masked
syslog.service                                                            enabled
system-update-cleanup.service                                             static
systemd-ask-password-console.service                                      static
systemd-ask-password-wall.service                                         static
systemd-backlight@.service                                                static
systemd-binfmt.service                                                    static
systemd-bless-boot.service                                                static
systemd-boot-check-no-failures.service                                    disabled
systemd-exit.service                                                      static
systemd-fsck-root.service                                                 enabled-runtime
systemd-fsck@.service                                                     static
systemd-fsckd.service                                                     static
systemd-halt.service                                                      static
systemd-hibernate-resume@.service                                         static
systemd-hibernate.service                                                 static
systemd-hostnamed.service                                                 static
systemd-hwdb-update.service                                               static
systemd-hybrid-sleep.service                                              static
systemd-initctl.service                                                   static
systemd-journal-flush.service                                             static
systemd-journald.service                                                  static
systemd-kexec.service                                                     static
systemd-localed.service                                                   static
systemd-logind.service                                                    static
systemd-machine-id-commit.service                                         static
systemd-modules-load.service                                              static
systemd-networkd-wait-online.service                                      disabled
systemd-networkd.service                                                  disabled
systemd-poweroff.service                                                  static
systemd-quotacheck.service                                                static
systemd-random-seed.service                                               static
systemd-reboot.service                                                    static
systemd-remount-fs.service                                                static
systemd-resolved.service                                                  disabled
systemd-rfkill.service                                                    static
systemd-suspend-then-hibernate.service                                    static
systemd-suspend.service                                                   static
systemd-sysctl.service                                                    static
systemd-sysusers.service                                                  static
systemd-time-wait-sync.service                                            disabled
systemd-timedated.service                                                 static
systemd-timesyncd.service                                                 enabled
systemd-tmpfiles-clean.service                                            static
systemd-tmpfiles-setup-dev.service                                        static
systemd-tmpfiles-setup.service                                            static
systemd-udev-settle.service                                               static
systemd-udev-trigger.service                                              static
systemd-udevd.service                                                     static
systemd-update-utmp-runlevel.service                                      static
systemd-update-utmp.service                                               static
systemd-user-sessions.service                                             static
systemd-volatile-root.service                                             static
udev.service                                                              static
umountfs.service                                                          masked
umountnfs.service                                                         masked
umountroot.service                                                        masked
urandom.service                                                           static
user-runtime-dir@.service                                                 static
user@.service                                                             static
x11-common.service                                                        masked
machine.slice                                                             static
user.slice                                                                static
dbus.socket                                                               static
ssh.socket                                                                disabled
syslog.socket                                                             static
systemd-fsckd.socket                                                      static
systemd-initctl.socket                                                    static
systemd-journald-audit.socket                                             static
systemd-journald-dev-log.socket                                           static
systemd-journald.socket                                                   static
systemd-networkd.socket                                                   disabled
systemd-rfkill.socket                                                     static
systemd-udevd-control.socket                                              static
systemd-udevd-kernel.socket                                               static
dev-disk-by\x2duuid-607d0aa4\x2ddaab\x2d477a\x2d9f5a\x2db233acd2906a.swap generated
basic.target                                                              static
bluetooth.target                                                          static
boot-complete.target                                                      static
cryptsetup-pre.target                                                     static
cryptsetup.target                                                         static
ctrl-alt-del.target                                                       disabled
default.target                                                            static
emergency.target                                                          static
exit.target                                                               disabled
final.target                                                              static
getty-pre.target                                                          static
getty.target                                                              static
graphical.target                                                          static
halt.target                                                               disabled
hibernate.target                                                          static
hybrid-sleep.target                                                       static
initrd-fs.target                                                          static
initrd-root-device.target                                                 static
initrd-root-fs.target                                                     static
initrd-switch-root.target                                                 static
initrd.target                                                             static
kexec.target                                                              disabled
local-fs-pre.target                                                       static
local-fs.target                                                           static
multi-user.target                                                         static
network-online.target                                                     static
network-pre.target                                                        static
network.target                                                            static
nss-lookup.target                                                         static
nss-user-lookup.target                                                    static
paths.target                                                              static
poweroff.target                                                           disabled
printer.target                                                            static
reboot.target                                                             disabled
remote-cryptsetup.target                                                  disabled
remote-fs-pre.target                                                      static
remote-fs.target                                                          enabled
rescue-ssh.target                                                         static
rescue.target                                                             static
rpcbind.target                                                            static
runlevel0.target                                                          disabled
runlevel1.target                                                          static
runlevel2.target                                                          static
runlevel3.target                                                          static
runlevel4.target                                                          static
runlevel5.target                                                          static
runlevel6.target                                                          disabled
shutdown.target                                                           static
sigpwr.target                                                             static
sleep.target                                                              static
slices.target                                                             static
smartcard.target                                                          static
sockets.target                                                            static
sound.target                                                              static
suspend-then-hibernate.target                                             static
suspend.target                                                            static
swap.target                                                               static
sysinit.target                                                            static
system-update-pre.target                                                  static
system-update.target                                                      static
time-sync.target                                                          static
timers.target                                                             static
umount.target                                                             static
apt-daily-upgrade.timer                                                   enabled
apt-daily.timer                                                           enabled
fstrim.timer                                                              disabled
logrotate.timer                                                           enabled
man-db.timer                                                              enabled
systemd-tmpfiles-clean.timer                                              static

231 unit files listed.

root@ipxpy:~#



root@ipxpy:~# systemctl list-unit-files --state=enabled
UNIT FILE                              STATE
apache2.service                        enabled
apparmor.service                       enabled
autovt@.service                        enabled
console-setup.service                  enabled
cron.service                           enabled
dbus-org.freedesktop.timesync1.service enabled
getty@.service                         enabled
keyboard-setup.service                 enabled
networking.service                     enabled
rsyslog.service                        enabled
ssh.service                            enabled
sshd.service                           enabled
syslog.service                         enabled
systemd-timesyncd.service              enabled
remote-fs.target                       enabled
apt-daily-upgrade.timer                enabled
apt-daily.timer                        enabled
logrotate.timer                        enabled
man-db.timer                           enabled

19 unit files listed.




root@ipxpy:~# systemctl list-unit-files --state=disabled
UNIT FILE                              STATE
apache-htcacheclean.service            disabled
apache-htcacheclean@.service           disabled
apache2@.service                       disabled
console-getty.service                  disabled
debug-shell.service                    disabled
ifupdown-wait-online.service           disabled
serial-getty@.service                  disabled
systemd-boot-check-no-failures.service disabled
systemd-networkd-wait-online.service   disabled
systemd-networkd.service               disabled
systemd-resolved.service               disabled
systemd-time-wait-sync.service         disabled
ssh.socket                             disabled
systemd-networkd.socket                disabled
ctrl-alt-del.target                    disabled
exit.target                            disabled
halt.target                            disabled
kexec.target                           disabled
poweroff.target                        disabled
reboot.target                          disabled
remote-cryptsetup.target               disabled
runlevel0.target                       disabled
runlevel6.target                       disabled
fstrim.timer                           disabled

24 unit files listed.
root@ipxpy:~#


You can check the systemd boot time and other boot-related information using the systemd-analyze command:

root@ipxpy:~# systemd-analyze
Startup finished in 3.060s (kernel) + 922ms (userspace) = 3.983s
graphical.target reached after 906ms in userspace


root@ipxpy:~# systemd-analyze blame
           501ms dev-sda1.device
           313ms systemd-journald.service
           211ms systemd-udev-trigger.service
           203ms apache2.service
           140ms apparmor.service
           130ms systemd-logind.service
           102ms keyboard-setup.service
            91ms systemd-timesyncd.service
            73ms systemd-user-sessions.service
            70ms networking.service
            67ms rsyslog.service
            49ms ifupdown-pre.service
            41ms systemd-tmpfiles-setup-dev.service
            41ms systemd-udevd.service
            38ms systemd-sysusers.service
            33ms console-setup.service
            32ms systemd-journal-flush.service
            29ms user@0.service
            27ms systemd-random-seed.service
            25ms dev-disk-by\x2duuid-607d0aa4\x2ddaab\x2d477a\x2d9f5a\x2db233acd2906a.swap
            25ms systemd-remount-fs.service
            23ms systemd-tmpfiles-clean.service
            21ms systemd-update-utmp.service
            20ms systemd-modules-load.service
            15ms systemd-tmpfiles-setup.service
            13ms ssh.service
            12ms kmod-static-nodes.service
            12ms systemd-update-utmp-runlevel.service
            11ms systemd-sysctl.service
            11ms sys-kernel-debug.mount
            11ms dev-hugepages.mount
            10ms proc-sys-fs-binfmt_misc.mount
             8ms user-runtime-dir@0.service
             7ms dev-mqueue.mount
root@ipxpy:~#

Systemd logs are stored in the journal. You can view them using the journalctl command. For example, to view the latest systemd journal entries:

root@ipxpy:~# journalctl -xe
Sep 19 10:13:50 ipxpy systemd[1]: session-3.scope: Succeeded.
-- Subject: Unit succeeded
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- The unit session-3.scope has successfully entered the 'dead' state.
Sep 19 10:13:50 ipxpy systemd-logind[380]: Session 3 logged out. Waiting for processes to exit.
Sep 19 10:13:50 ipxpy systemd-logind[380]: Removed session 3.
-- Subject: Session 3 has been terminated
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- Documentation: https://www.freedesktop.org/wiki/Software/systemd/multiseat
--
-- A session with the ID 3 has been terminated.
Sep 19 10:15:53 ipxpy sshd[602]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.0.102  user=root
Sep 19 10:15:55 ipxpy sshd[602]: Failed password for root from 192.168.0.102 port 63420 ssh2
Sep 19 10:16:33 ipxpy sshd[602]: Accepted password for root from 192.168.0.102 port 63420 ssh2
Sep 19 10:16:33 ipxpy sshd[602]: pam_unix(sshd:session): session opened for user root by (uid=0)
Sep 19 10:16:33 ipxpy systemd-logind[380]: New session 4 of user root.
-- Subject: A new session 4 has been created for user root
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- Documentation: https://www.freedesktop.org/wiki/Software/systemd/multiseat
--
-- A new session with the ID 4 has been created for the user root.
--
-- The leading process of the session is 602.
Sep 19 10:16:33 ipxpy systemd[1]: Started Session 4 of user root.
-- Subject: A start job for unit session-4.scope has finished successfully
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit session-4.scope has finished successfully.
--
-- The job identifier is 390.
Sep 19 10:17:01 ipxpy CRON[780]: pam_unix(cron:session): session opened for user root by (uid=0)
Sep 19 10:17:01 ipxpy CRON[781]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Sep 19 10:17:01 ipxpy CRON[780]: pam_unix(cron:session): session closed for user root
Sep 19 11:17:01 ipxpy CRON[806]: pam_unix(cron:session): session opened for user root by (uid=0)
Sep 19 11:17:01 ipxpy CRON[807]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Sep 19 11:17:01 ipxpy CRON[806]: pam_unix(cron:session): session closed for user root
Sep 19 12:17:01 ipxpy CRON[828]: pam_unix(cron:session): session opened for user root by (uid=0)
Sep 19 12:17:01 ipxpy CRON[829]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Sep 19 12:17:01 ipxpy CRON[828]: pam_unix(cron:session): session closed for user root

root@ipxpy:~#

05. Run Levels

In Linux, the run level stands for the current state of the operating system. Run levels define which system services are running. Previously, SysVinit identified run levels by number. However, .target files now replace run levels in Systemd.

Further, Systemd activates the default.target unit by default when the system boots. Let’s check our default target:

root@ipxpy:~# journalctl -xe
Sep 19 10:13:50 ipxpy systemd[1]: session-3.scope: Succeeded.
-- Subject: Unit succeeded
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- The unit session-3.scope has successfully entered the 'dead' state.
Sep 19 10:13:50 ipxpy systemd-logind[380]: Session 3 logged out. Waiting for processes to exit.
Sep 19 10:13:50 ipxpy systemd-logind[380]: Removed session 3.
-- Subject: Session 3 has been terminated
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- Documentation: https://www.freedesktop.org/wiki/Software/systemd/multiseat
--
-- A session with the ID 3 has been terminated.
Sep 19 10:15:53 ipxpy sshd[602]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.0.102  user=root
Sep 19 10:15:55 ipxpy sshd[602]: Failed password for root from 192.168.0.102 port 63420 ssh2
Sep 19 10:16:33 ipxpy sshd[602]: Accepted password for root from 192.168.0.102 port 63420 ssh2
Sep 19 10:16:33 ipxpy sshd[602]: pam_unix(sshd:session): session opened for user root by (uid=0)
Sep 19 10:16:33 ipxpy systemd-logind[380]: New session 4 of user root.
-- Subject: A new session 4 has been created for user root
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- Documentation: https://www.freedesktop.org/wiki/Software/systemd/multiseat
--
-- A new session with the ID 4 has been created for the user root.
--
-- The leading process of the session is 602.
Sep 19 10:16:33 ipxpy systemd[1]: Started Session 4 of user root.
-- Subject: A start job for unit session-4.scope has finished successfully
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit session-4.scope has finished successfully.
--
-- The job identifier is 390.
Sep 19 10:17:01 ipxpy CRON[780]: pam_unix(cron:session): session opened for user root by (uid=0)
Sep 19 10:17:01 ipxpy CRON[781]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Sep 19 10:17:01 ipxpy CRON[780]: pam_unix(cron:session): session closed for user root
Sep 19 11:17:01 ipxpy CRON[806]: pam_unix(cron:session): session opened for user root by (uid=0)
Sep 19 11:17:01 ipxpy CRON[807]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Sep 19 11:17:01 ipxpy CRON[806]: pam_unix(cron:session): session closed for user root
Sep 19 12:17:01 ipxpy CRON[828]: pam_unix(cron:session): session opened for user root by (uid=0)
Sep 19 12:17:01 ipxpy CRON[829]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Sep 19 12:17:01 ipxpy CRON[828]: pam_unix(cron:session): session closed for user root

root@ipxpy:~#