Systemd is the default init system on Red Hat Enterprise Linux 8, responsible for managing services, sockets, timers, and other units from boot through shutdown. Understanding how to control systemd services is essential for anyone administering RHEL 8 servers in production. This tutorial covers the core systemctl commands, how to inspect logs with journalctl, and how to create and override custom service units. By the end, you will be able to define your own application as a managed systemd service.

Prerequisites

  • A running RHEL 8 system (physical, VM, or cloud instance)
  • A user account with sudo privileges or direct root access
  • Basic familiarity with the Linux command line

Step 1 — Controlling Services with systemctl

The systemctl command is the primary interface to systemd. Use it to start, stop, restart, and reload services. Reloading asks a service to re-read its configuration without fully restarting, which avoids connection drops where supported.

# Start a service
sudo systemctl start httpd

# Stop a service
sudo systemctl stop httpd

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

# Reload configuration without restarting
sudo systemctl reload httpd

# Check the current status
sudo systemctl status httpd

Step 2 — Enabling and Disabling Services at Boot

Enabling a service creates the necessary symlinks so that systemd starts it automatically at the appropriate boot target. Disabling removes those symlinks. Neither command starts or stops the service immediately — combine with --now to do both in one step.

# Enable httpd to start at boot
sudo systemctl enable httpd

# Disable httpd from starting at boot
sudo systemctl disable httpd

# Enable AND start immediately
sudo systemctl enable --now httpd

# Disable AND stop immediately
sudo systemctl disable --now httpd

Step 3 — Listing and Inspecting Units

To see all active services and their states, filter the unit list by type. You can also check whether a unit is active or enabled with quick one-liner commands.

# List all loaded service units
sudo systemctl list-units --type=service

# List all installed unit files (including disabled)
sudo systemctl list-unit-files --type=service

# Check if a service is active
sudo systemctl is-active httpd

# Check if a service is enabled
sudo systemctl is-enabled httpd

Step 4 — Viewing Logs with journalctl

Systemd captures all service output in the journal. Use journalctl -u to filter logs by unit name. The -f flag follows new entries in real time, similar to tail -f.

# View all journal entries for a service
sudo journalctl -u httpd

# Follow log output in real time
sudo journalctl -u httpd -f

# Show entries since last boot only
sudo journalctl -u httpd -b

# Show the last 50 lines
sudo journalctl -u httpd -n 50

Step 5 — Creating a Custom Service Unit

Place custom unit files in /etc/systemd/system/ so they are not overwritten by package updates. The example below creates a simple unit that runs a Python application as the myapp user.

# Create the unit file
sudo tee /etc/systemd/system/myapp.service <<'EOF'
[Unit]
Description=My Python Application
After=network.target

[Service]
Type=simple
User=myapp
WorkingDirectory=/opt/myapp
ExecStart=/opt/myapp/venv/bin/python app.py
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
EOF

# Reload systemd to pick up the new file
sudo systemctl daemon-reload

# Enable and start the new service
sudo systemctl enable --now myapp

Step 6 — Overriding Unit Settings with systemctl edit

Rather than editing a vendor-provided unit file directly, use systemctl edit to create a drop-in override. Systemd merges the override with the original, so only the settings you specify are changed. This approach survives package upgrades cleanly.

# Open (or create) a drop-in override for httpd
sudo systemctl edit httpd

# This creates /etc/systemd/system/httpd.service.d/override.conf
# Example override content to increase restart limits:
# [Service]
# Restart=always
# RestartSec=10s

# After editing, reload and restart
sudo systemctl daemon-reload
sudo systemctl restart httpd

# View the effective merged unit
sudo systemctl cat httpd

Conclusion

You now know how to start, stop, enable, and disable services, list all running units, inspect service logs through the journal, create a custom service unit file, and safely override vendor units using drop-in files. These skills form the operational foundation for managing any long-running process on RHEL 8.

Next steps: How to Configure Firewalld on RHEL 8, How to Manage SELinux Policies on RHEL 8, and How to Configure sudo and Sudoers on RHEL 8.