Red Hat System Administration I · RH124

Chapter 16

Controlling Services and Daemons
systemd units · systemctl · Enabling at boot · Dependencies
CIS126RH — Mesa Community College

Chapter Objective

Start, stop, restart, enable, disable, and inspect systemd-managed services, and understand how service state relates to boot-time behavior.

Key Commands

  • systemctl start
  • systemctl stop
  • systemctl status
  • systemctl enable
  • systemctl disable

systemd and Units

systemd is the init system and service manager on RHEL — the first process the kernel starts (PID 1), responsible for bringing the rest of the system up and managing every service afterward. Everything systemd manages is represented as a unit.

Unit TypeExtensionManages
Service.serviceA background process / daemon
Socket.socketA network or IPC socket, often used to start a service on demand
Target.targetA group of units representing a system state (like a boot milestone)
Timer.timerA scheduled trigger, similar in purpose to cron
Mount.mountA filesystem mount point
Why It Matters — Almost every piece of RHEL's runtime behavior — from sshd to networking to logging — is a systemd unit under the hood. systemctl is the one tool you'll reach for constantly, across nearly every administrative task.

Checking and Changing Service State

# Check whether a service is currently running, and recent log lines
systemctl status sshd

# Start a service right now (does not affect boot behavior)
sudo systemctl start sshd

# Stop a running service
sudo systemctl stop sshd

# Restart a service (stop, then start)
sudo systemctl restart sshd

# Reload configuration WITHOUT dropping active connections, if supported
sudo systemctl reload sshd

# Reload if supported, otherwise fall back to a full restart
sudo systemctl reload-or-restart sshd
Tip — reload vs. restartreload is gentler when available — it applies configuration changes without interrupting active connections (important for something like sshd with sessions already open). Not every service supports it; restart always works but briefly drops the service entirely.

Controlling Startup at Boot

Whether a service is currently active and whether it's enabled to start at boot are two entirely separate settings.

# Enable a service to start automatically at boot (doesn't start it now)
sudo systemctl enable sshd

# Enable AND start it immediately, in one command
sudo systemctl enable --now sshd

# Disable a service from starting at boot (doesn't stop it now)
sudo systemctl disable sshd

# Check whether a service is enabled
systemctl is-enabled sshd

# Check whether a service is currently active
systemctl is-active sshd
Warning — Enabled ≠ Running — A service can be enabled but not currently running (if it was manually stopped), or running but not enabled (if it was started manually without enabling it — it won't survive a reboot). Always check both states independently rather than assuming one implies the other.

Masking Units

Masking goes a step further than disabling: it links the unit file to /dev/null, preventing the service from being started at all — even manually, even as a dependency of another unit.

# Prevent a service from being started by any means
sudo systemctl mask telnet.socket

# Reverse it
sudo systemctl unmask telnet.socket
Note — When to Mask — Masking is the right tool when you need to guarantee a service can never start by accident — for example, blocking a legacy or insecure service entirely, even if another package tries to pull it in as a dependency.

Inspecting Unit Details

# List all currently loaded units
systemctl list-units

# List all service units, including inactive ones
systemctl list-units --type=service --all

# Show the raw contents of a unit file
systemctl cat sshd

# Show detailed properties of a unit
systemctl show sshd

# List every failed unit — a fast health check
systemctl --failed
Tip — systemctl --failed Is a Great First Step — When troubleshooting "something's wrong" on a system, systemctl --failed is often the fastest way to see whether a specific service is the culprit before digging further.

A Quick Look at Logs

systemd's logging component, the journal, captures output from every unit. A full treatment comes in a later chapter, but a couple of commands are worth knowing now while troubleshooting service state.

# Show recent log entries for a specific unit
journalctl -u sshd

# Follow a unit's log entries live
journalctl -u sshd -f

Key Terms for Chapter 16

systemd
The init system and service manager on RHEL, running as PID 1
unit
Any resource systemd manages — services, sockets, targets, timers, mounts, and more
service unit
A unit representing a background process or daemon (.service)
target
A unit grouping other units to represent a system state or boot milestone
enabled
A unit configured to start automatically at boot — independent of whether it's currently running
active
A unit that is currently running — independent of whether it's enabled at boot
masked
A unit explicitly prevented from being started by any means, including as a dependency
journal
systemd's centralized logging component, queried with journalctl

Review Questions

  1. What is the difference between a service being "active" and being "enabled"?
  2. Write a single command that both enables httpd to start at boot AND starts it immediately.
  3. What's the difference between systemctl restart and systemctl reload?
  4. Why might systemctl disable not be enough to guarantee a service never starts, and what command would guarantee it?
  5. What command gives you a fast overview of every currently failed unit on the system?
  6. Write a command that shows the live, following log output for the sshd service.
  7. What file extension identifies a systemd timer unit, and what is it generally used for?
1 / 10