Skip to main content
In this demo we’ll interact directly with systemctl so you can see how systemd services behave in real time and how to manage them in production environments. We’ll switch to the root user to avoid repeatedly typing sudo during the demo.
A dark presentation slide titled "Demo — Working With systemctl." On the right is a neon-blue outline icon of a terminal/command window.
Switch to root:
Check the status of the sshd service (example output shown):
What the important fields mean:
  • Loaded: where the unit file comes from and its enablement status.
  • Active: the runtime state (e.g., active (running), inactive (dead)).
  • Trailing journal-like lines: recent log messages from the service (systemd journal).
Common service lifecycle commands
  • Start a service: systemctl start <service>
  • Stop a service: systemctl stop <service>
  • Restart a service (stop then start): systemctl restart <service>
  • Reload service config (if supported): systemctl reload <service>
  • Try reload, fall back to restart: systemctl reload-or-restart <service>
Stopping and starting services — live examples Stop sshd and then check its status:
Start sshd again:
Restart vs reload
  • systemctl restart <service>: performs a full stop and start. Use when a full restart is acceptable (there will be downtime).
  • systemctl reload <service>: asks the service to reload its configuration without stopping. Only works if the unit implements a reload action.
  • systemctl reload-or-restart <service>: preferred in automation — it attempts reload and falls back to restart if reload is not supported.
Prefer reload when the service supports it to avoid downtime. If reload is not implemented, use restart or reload-or-restart to attempt a seamless update with a fallback.
Enablement and script-friendly checks
  • systemctl enable <service>: create the boot-time symlink so the service starts automatically.
  • systemctl disable <service>: remove the boot-time symlink so the service does not start at boot.
  • systemctl is-active <service>: returns active, inactive, etc. — useful in scripts.
  • systemctl is-enabled <service>: returns enabled, disabled, etc. — useful in scripts.
  • systemctl list-units --type=service --state=active: list active services; remove --state=active to broaden the list.
Example sequence showing reload, enable/disable and checks:
Quick reference: common systemctl commands Masking and unmasking services
  • Masking creates a symlink from the unit file path to /dev/null, preventing the unit from being started manually or as a dependency.
  • To start a masked service you must first unmask it.
Example:
Important: after editing or adding unit files, run systemctl daemon-reload so systemd re-reads unit definitions. Further reading and references This concludes the demo on interacting with systemctl and managing services in real time.

Watch Video

Practice Lab