Chapter 9: Services and the boot process

Managing services with systemd

Almost everything useful a server does, such as serving web pages, keeping time, accepting SSH logins or running scheduled jobs, is done by a service: a program that runs in the background without a terminal. On RHEL, a program called systemd starts, stops and watches them. systemctl is how you talk to it.

systemd and units

systemd is the first process the kernel starts (PID 1). It reads configuration files called units, each describing one thing it manages. The type is the file's suffix:

Unit typeManagesExample
.serviceA background programsshd.service, crond.service
.targetA group of units that mark a state of the systemmulti-user.target
.socketA listening network or local socket that starts a service on demanddbus.socket
.timerA schedule that starts another unitdnf-makecache.timer
.mountA mounted file systemboot-efi.mount

You can leave out .service when you type a service name: systemctl status crond means crond.service.

Asking about a service

[root@servera ~]# systemctl status crond
● crond.service - Command Scheduler
     Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; preset: enabled)
     Active: active (running) since Sat 2026-10-03 16:36:40 UTC; 4s ago
   Main PID: 642 (crond)
      Tasks: 1 (limit: 5820)
     Memory: 1.0M (peak: 1.3M)
        CPU: 6ms
     CGroup: /system.slice/crond.service
             └─642 /usr/sbin/crond -n

Oct 03 16:36:40 servera.lab.example.com systemd[1]: Started Command Scheduler.
Oct 03 16:36:40 servera.lab.example.com crond[642]: (CRON) STARTUP (1.5.7)

Read it from the top:

LineTells you
● / ○A green dot: active. A hollow dot: inactive. Red: failed.
Loaded:Where the unit file is, and whether it is enabled (starts at boot)
Active:The current state and since when
Main PID, CGroupThe processes that belong to it
log linesThe last few journal lines, to see what it said

For scripts, ask a single question and use the answer: systemctl is-active NAME prints active or inactive, systemctl is-enabled NAME prints enabled, disabled or masked, and both set the exit status.

Now versus at boot

This is the central idea of the lesson. Every service has two independent properties:

Two separate questions: Select a combination to see what it means.

CommandChangesAffects
systemctl start NAMEStarts itNow only
systemctl stop NAMEStops itNow only
systemctl restart NAMEStops, then startsNow
systemctl reload NAMEAsks it to re-read its configuration, without stoppingNow
systemctl enable NAMEStarts it at every bootBoot only
systemctl disable NAMEStops it from starting at bootBoot only
systemctl enable --now NAMEBothBoot and now
systemctl disable --now NAMEBothBoot and now
systemctl mask NAMEMakes it impossible to startAlways

enable works by creating a symbolic link, which you can see in its output:

[root@servera ~]# systemctl disable crond
Removed "/etc/systemd/system/multi-user.target.wants/crond.service".
[root@servera ~]# systemctl enable crond
Created symlink /etc/systemd/system/multi-user.target.wants/crond.service → /usr/lib/systemd/system/crond.service.

mask goes further than disable: a disabled service can still be started by hand or by another service that needs it, but a masked one cannot.

[root@servera ~]# systemctl mask bluetooth
Created symlink /etc/systemd/system/bluetooth.service → /dev/null.
[root@servera ~]# systemctl start bluetooth
Failed to start bluetooth.service: Unit bluetooth.service is masked.

Listing units

[root@servera ~]# systemctl list-units --type=service --state=running
[root@servera ~]# systemctl list-unit-files --type=service
[root@servera ~]# systemctl --failed
  UNIT LOAD ACTIVE SUB DESCRIPTION
0 loaded units listed.

list-units shows what is loaded now; list-unit-files shows what is installed and whether each is enabled; --failed is the first thing to run when something is wrong.

Try it

Check your understanding