systemctlsystemd is the default init system in most modern Linux distributions. It manages system boot, services, and processes via the systemctl command.
systemctl?systemctl is the control interface for systemd. It allows you to start, stop, enable, disable, restart, and monitor system services and units.
systemctl start service # Start service now
systemctl stop service # Stop service
systemctl restart service # Restart service
systemctl reload service # Reload config without stopping
systemctl status service # Show service status
Example:
sudo systemctl restart apache2
systemctl enable service # Start at boot
systemctl disable service # Do not start at boot
systemctl is-enabled service # Check boot status
Example:
sudo systemctl enable ssh
systemctl list-units --type=service # Active services
systemctl list-unit-files # All units and their state
journalctl)journalctl -u service # View logs for a service
journalctl -u service -f # Follow logs (live)
journalctl -xe # Show recent errors
Example:
journalctl -u nginx -f
systemctl daemon-reexec # Re-exec systemd itself
systemctl daemon-reload # Reload unit files
Use after editing unit files manually.
/etc/systemd/system/ or /lib/systemd/system/~/.config/systemd/user/After creating or editing a unit file, run:
sudo systemctl daemon-reload
| Command | Description |
|---|---|
start, stop, restart |
Manage service state immediately |
enable, disable |
Control autostart on boot |
status |
Show active service status |
list-units |
View running services |
daemon-reload |
Reload changed unit files |
journalctl -u name |
View logs for a service |
sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl status apache2
journalctl -u apache2 -f
Understanding systemctl is essential for controlling services in modern Linux systems. It provides centralized, efficient service management for both system and user sessions.