ITNuvoAkademiya
Academy homePackagesPlaylistsToolsSubnet calculatorSearchGlossary
CiscoCCNA · CCNA: networking fundamentals1. Introduction2. Network Fundamentals3. Network Access4. IP Connectivity5. IP Services6. IPv67. Security Fundamentals8. AutomationCCNP: Enterprise networks · coming soon
LinuxLinux: system administrator üçün · Linux for system administrators1. Getting to know Linux2. Working with text3. Users and permissions4. Processes and packages5. Inside the system6. Monitoring and logs7. NetworkingRed Hat Enterprise Linux · Red Hat Enterprise Linux: from beginner to advanced1. Getting started2. Packages3. Users and permissions4. SELinux5. Services6. Storage7. Networking8. Building services9. Boot and recovery10. DevOps11. Security and monitoring
FortinetFortiGate Administrator · FortiGate Administrator: from first login to ZTNA1. Getting to know FortiGate2. Routing, policy and NAT3. Security profiles4. Users and logs5. Resilience, SD-WAN and automation6. VDOM7. VPN and ZTNA8. Proxy9. DMZ
MonitoringZabbix · Zabbix: from installation to alerts1. Introduction2. Installation and the database3. Basics: groups, templates, users4. Connecting devices5. Alerts, Grafana and the API
VirtualizationProxmox VE · coming soonVMware ESXi · coming soon
My account / Sign in
AZENRU
← itnuvo.com

systemd: units, targets, systemctl

Lesson 5.18 minIntermediateDecember 1, 2026
Open

This lesson is open to everyone. The other lessons open with a package: sign in or sign up, then choose a package.

Key points

  • systemctl enable --now httpd — start now and at boot; RHCSA has the condition "must keep working after a reboot" in every task.
  • systemctl status, is-active, is-enabled, --failed, list-units --type=service.
  • Unit files: /usr/lib/systemd/system/ (package), /etc/systemd/system/ (admin, takes precedence); after a change, daemon-reload.
  • Targets: multi-user.target (server), graphical.target; systemctl get-default / set-default.
  • systemctl mask blocks a service completely (e.g. iptables conflicting with firewalld); systemctl edit creates an override.

Now and at boot

We covered systemd in detail in the Ubuntu course. On RHEL the main difference is philosophical: installing a package does not start the service.

srv-web01
[ali@srv-web01 ~]$ systemctl is-active httpd; systemctl is-enabled httpd
inactive
disabled
[ali@srv-web01 ~]$ sudo systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[ali@srv-web01 ~]$ systemctl is-active httpd; systemctl is-enabled httpd
active
enabled
CommandNowAt boot
start / stop✓—
enable / disable—✓
enable --now / disable --now✓✓
restartStop + start—
reloadRe-read configuration—
mask / unmaskBlocks it (start does not work either)✓

In RHCSA almost every task has the condition "must keep working after a reboot". The examiner reboots the server and checks — running start without enable means losing the task.

Reading the state

srv-web01
[ali@srv-web01 ~]$ systemctl list-units --type=service --state=running | head -n 5
  UNIT                     LOAD   ACTIVE SUB     DESCRIPTION
  auditd.service           loaded active running Security Auditing Service
  chronyd.service          loaded active running NTP client/server
  crond.service            loaded active running Command Scheduler
  firewalld.service        loaded active running firewalld - dynamic firewall daemon
[ali@srv-web01 ~]$ systemctl list-unit-files --type=service | grep enabled | wc -l
31
[ali@srv-web01 ~]$ systemctl --failed
  UNIT LOAD ACTIVE SUB DESCRIPTION
0 loaded units listed.

Service names on RHEL differ from Ubuntu: sshd (ssh on Ubuntu), crond (cron), chronyd (chrony), httpd (apache2).

Unit files and overrides

srv-web01
[ali@srv-web01 ~]$ systemctl cat httpd | head -n 12
# /usr/lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
Wants=httpd-init.service
After=network.target remote-fs.target nss-lookup.target httpd-init.service
Documentation=man:httpd.service(8)

[Service]
Type=notify
Environment=LANG=C
ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful

An override so httpd restarts by itself when it fails:

srv-web01
[ali@srv-web01 ~]$ sudo mkdir -p /etc/systemd/system/httpd.service.d
[ali@srv-web01 ~]$ printf "[Service]\nRestart=on-failure\nRestartSec=5\n" | sudo tee /etc/systemd/system/httpd.service.d/restart.conf
[ali@srv-web01 ~]$ sudo systemctl daemon-reload
[ali@srv-web01 ~]$ systemctl show httpd -p Restart
Restart=on-failure

sudo systemctl edit httpd creates the same file interactively. Do not edit the file in /usr/lib/systemd/system/ directly — it will be lost when the package updates.

Targets

srv-web01
[ali@srv-web01 ~]$ systemctl get-default
multi-user.target
[ali@srv-web01 ~]$ sudo systemctl set-default multi-user.target
[ali@srv-web01 ~]$ systemctl list-dependencies multi-user.target | head -n 6
multi-user.target
● ├─auditd.service
● ├─chronyd.service
● ├─crond.service
● ├─firewalld.service
● ├─httpd.service
TargetOld runlevelMeaning
poweroff.target0Power off
rescue.target1Single user, recovery
multi-user.target3Server: network, services, no graphics
graphical.target5Graphical desktop
reboot.target6Reboot

To switch a server with a graphical interface to text mode at boot: set-default multi-user.target. To switch now (without rebooting): systemctl isolate multi-user.target.

mask: blocking completely

When two services do the same job (for example firewalld and the old iptables-services), so you do not start one by accident:

srv-web01
[ali@srv-web01 ~]$ sudo systemctl mask iptables
Created symlink /etc/systemd/system/iptables.service → /dev/null.
[ali@srv-web01 ~]$ sudo systemctl start iptables
Failed to start iptables.service: Unit iptables.service is masked.

mask points the unit file at /dev/null. To undo: systemctl unmask iptables.

Lab: start httpd

The "Start httpd" task in the Red Hat simulator:

  1. Start httpd now and at boot.
  2. Open the test page from the server itself.
srv-web01
[ali@srv-web01 ~]$ sudo systemctl enable --now httpd
[ali@srv-web01 ~]$ systemctl is-active httpd; systemctl is-enabled httpd
active
enabled
[ali@srv-web01 ~]$ curl -s http://localhost | grep -o "<title>.*</title>"
  1. (On your own VM) create a Restart=on-failure override for httpd, run daemon-reload, check with systemctl show httpd -p Restart. Then kill the httpd process with kill -9 and see it come back by itself after 5 seconds.
  2. systemctl get-default — it should be multi-user.target.

Check: the task is green; is-enabled → enabled.

Check yourself

5 questions · answers are shown instantly · 3 correct answers complete the lesson

1Which command makes a service run now and come back after a reboot?

In RHCSA, forgetting enable means losing the task.

2What is the SSH service called on RHEL?

ssh on Ubuntu, sshd on RHEL.

3What is the right way to change a package's unit file?

An override is not lost on a package update.

4What does systemctl mask iptables do?

The unit file is pointed at /dev/null.

5The server should boot into text mode, not graphics. Which command?

set-default sets the boot target.
Was this lesson useful?

Comments

Sign in to comment.