Table of Contents
- Introduction to systemd
- Unit File Types
- Service Unit Structure
- Inspecting the SSH Daemon Service
- Editing and Reverting a Unit
- Monitoring Service Status
- Managing Service Lifecycle
- Enabling and Disabling at Boot
- Masking and Unmasking Services
- Listing All Service Units
- Further Reading
Introduction to systemd
When Linux boots, systemd orchestrates service startup in parallel while respecting dependencies. If a critical service fails, systemd can restart it automatically, ensuring high availability. All behavior is defined by unit files—plain-text configurations that tell systemd how to manage resources.Learn more about systemd on the Official Freedesktop Wiki.
Unit File Types
Unit files end in.service, .socket, .device, .timer, and more. Here’s a quick overview:
Service Unit Structure
Service units reside in/etc/systemd/system/ or /usr/lib/systemd/system/. They have three main sections:
- ExecStart: Command to launch the service
- ExecReload: How to reload without a full restart
- Restart: Policy (
no,on-failure,always)
Inspecting the SSH Daemon Service
Most servers run the OpenSSH daemon (sshd) as a systemd service. View its complete unit file:
Editing and Reverting a Unit
To fully edit thesshd.service file:
Monitoring Service Status
Check detailed status and recent logs:Q to exit.
Managing Service Lifecycle
Usesystemctl for day-to-day operations:
Enabling and Disabling at Boot
Control automatic startup:--now to apply immediately:
Disabling and stopping
sshd.service will prevent all SSH logins.