Systemd Cheatsheet - Linux Service Management Commands

Master Linux service management with our Systemd cheatsheet. Quickly find commands for journalctl, systemctl, timedatectl, and hostnamectl for efficient system administration.

Systemd Cheatsheet

This cheatsheet provides essential Systemd commands for managing services and system information on Linux. Systemd is a widely adopted init system and service manager for Linux operating systems, offering robust features for controlling processes, managing system resources, and handling logging.

Journalctl: Systemd's Logging Utility

Efficiently view and filter system logs using journalctl. This section covers common commands for tailing logs, viewing boot messages, filtering by service, and time-based queries.

[cheats]
Journalctl tail like = journalctl -f
See all boot messages = journalctl -b
Logs from a service = journalctl -u nginx.service
Logs since a certain time = journalctl --since "time"
Get logs from today = journalctl --since "today"
Logs for certain priority = journalctl -p <PRIORITY>
Filter logs = journalctl _COMM=|_UID=|_HOSTNAME=

Systemctl: Managing Services and Units

Control and query the status of system services and other systemd units with systemctl. This includes listing units, checking statuses, starting, stopping, enabling, and disabling services.

List all services = systemctl list-unit-files --type=service
Show config file = systemctl cat <UNIT>
See failed services = systemctl --failed
List all units = systemctl list-unit-files
Show properties of a unit = systemctl show <UNITNAME>
Check if service is enabled = systemctl is-enabled <UNITNAME>
Start a service = systemctl start <SERVICENAME>
Stop a service = systemctl stop <SERVICENAME>
Restart a service = systemctl restart <SERVICENAME>
Reload a service = systemctl reload <SERVICENAME>
See service status =  systemctl status <SERVICENAME>
Enable a service = systemctl enable <SERVICENAME>
Disable a service = systemctl disable <SERVICENAME>
Kill all processes of a service = systemctl kill <SERVICENAME>
System halt = systemctl halt
Power off system = systemctl poweroff
Restart the system = systemctl restart
Suspend the system = systemctl suspend
Check current runlevel = systemctl get-default
Set default runlevel = systemctl set-default <TARGETNAME>

Systemd-Analyze: Performance and Boot Analysis

Understand system boot times and analyze performance with systemd-analyze. This tool helps identify bottlenecks during the boot process.

View details for boot = systemd-analyze

Timedatectl and Hostnamectl: System Information

Manage system time, date, and hostname using dedicated utilities. timedatectl provides an interface to control the system clock and timezone, while hostnamectl manages the system's hostname.

Show time and date = timedatectl
Show hostname = hostnamectl

External Resources