Skip to main content
Linux System Administration:

Systemd cheat sheet

Summary

Master systemd with this cheat sheet of common systemctl commands. It covers managing services, units, and timers, checking system state, performing actions like rebooting or powering off, and using journalctl for logs.

Introduction #

Systemd is the modern system and service manager for Linux operating systems, replacing traditional init systems like System V and Upstart. It is responsible for managing system startup, services, and processes.

The systemctl command is used to control systemd units, including services, sockets, timers, and targets.

This cheat sheet provides a quick reference for commonly used commands, enabling you to troubleshoot and optimize system behavior. For further details, refer to the official systemd documentation.

Common systemctl commands and options #

systemd dervices #

Typical service names follow a convention related to the software they manage. For example, nginx.service controls the Nginx web server, while ssh.service manages the OpenSSH server.

To check the status of a service:

systemctl status <service-name>

To start a service:

systemctl start <service-name>

To stop a service:

systemctl stop <service-name>

To restart a service:

systemctl restart <service-name>

To reload a service:

systemctl reload <service-name>

To enable a service at boot:

systemctl enable <service-name>

To disable a service at boot:

systemctl disable <service-name>

To check if a service is enabled or disabled:

systemctl is-enabled <service-name>

To view logs for a service:

journalctl -u <service-name>

systemd units #

A unit in systemd is a resource that systemd manages. Units can represent services, sockets, mount points, devices, and other system resources, each defined by a corresponding configuration file.

Listing units #

To list all active units:

systemctl list-units

To list all installed unit files:

systemctl list-unit-files

To list all failed units:

systemctl --failed

To filter specific unit types (e.g., services):

systemctl list-units --type=service

Using patterns with grep:

systemctl list-unit-files | grep disabled

Inspecting units #

To view the content of a unit file:

systemctl cat <unit-name>

To show properties of a unit:

systemctl show <unit-name>

To list dependencies of a unit:

systemctl list-dependencies <unit-name>

systemd timers #

Systemd timers are unit files that trigger the execution of services at scheduled times or intervals, replacing traditional cron jobs.

To list all active timers:

systemctl list-timers

To check the details of a timer:

systemctl status <timer-name>

To add a new timer:

systemctl enable <timer-name>

To pause a timer:

systemctl stop <timer-name>

To remove a timer:

systemctl disable <timer-name>

System state #

System state in systemd refers to the overall health and operational status of the system, including whether it is booted correctly, running properly, or encountering errors.

To view the current system state:

systemctl is-system-running

To reboot the system:

systemctl reboot

To power off the system:

systemctl poweroff

To suspend the system:

systemctl suspend

To hibernate the system:

systemctl hibernate

Common journalctl commands and options #

To view all logs (displays the entire system journal):

journalctl

Boot process logs #

To view logs related to the system boot process:

journalctl -b

To view logs from the previous boot:

journalctl -b -1

To list previous boot logs:

journalctl --list-boots

Time and date specific logs #

To follow logs in real-time (like tail -f to continuously show new log entries):

journalctl -f

To view logs from a relative time (e.g., last 1 hour):

journalctl --since "1 hour ago"

To view logs from the last 30 minutes:

journalctl --since "30 minutes ago"

To view logs for the past week:

journalctl --since "7 days ago"

View logs since a specific date and time:

journalctl --since "2025-03-15 08:00:00"

To view logs until a specific date and time:

journalctl --until "2025-03-15 18:00:00"

To view logs for a specific time range:

journalctl --since "2025-03-15 12:00:00" --until "2025-03-15 14:00:00"

To view logs from a specific day:

journalctl --since "2025-03-14" --until "2025-03-14 23:59:59"

To view logs from yesterday (from midnight of the previous day):

journalctl --since "yesterday"

Application specific logs #

To filter logs for a specific unit, e.g. nginx.service:

journalctl -u <unit-name>

To view Linux kernel logs:

journalctl -k

To view logs for a specific user process, user ID 1000:

journalctl _UID=1000

To view logs for a specific executable:

journalctl /usr/bin/your_program

Error and alert logs #

View logs with priority filtering (logs with priority 3 (errors) and higher (more critical)):

journalctl -p 3

or

journalctl -p err

To show only error, critical, and alert messages:

journalctl -p err..alert

House keeping #

To delete logs older than 7 days:

sudo journalctl --vacuum-time=7d

To clear the journal logs (limits journal log size to 500MB):

sudo journalctl --vacuum-size=500M

To remove logs older than a specific date (e.g., before March 1, 2025):

sudo journalctl --vacuum-time="2025-03-01"

To clear logs for a specific service (e.g., nginx):

sudo journalctl --vacuum-size=500M -u nginx.service

To flush all journal logs (DANGEROUS – permanently deletes all logs!):

sudo journalctl --rotate  
sudo journalctl --vacuum-time=1s

To manually remove all logs and restart systemd-journald:

sudo rm -rf /var/log/journal/*
sudo systemctl restart systemd-journald

FAQ's #

Most common questions and brief, easy-to-understand answers on the topic:

How do I check the status of a service in systemd?

Use systemctl status service-name to check the current status and logs of a systemd service.

How can I restart a failed systemd unit?

Use systemctl restart service-name to restart a failed service. Check logs with journalctl -u service-name.

How do I list all systemd units?

Run systemctl list-units to see active units or systemctl list-unit-files for all installed unit files.

What is a systemd timer and how do I use it?

A systemd timer is a unit that triggers service execution at specific times. Use systemctl list-timers to see active timers.

How can I disable a service from starting at boot?

Run systemctl disable service-name to prevent a service from starting at boot.

Further readings #

Sources and recommended, further resources on the topic:

Author

Jonas Jared Jacek • J15k

Jonas Jared Jacek (J15k)

Jonas works as project manager, web designer, and web developer since 2001. On top of that, he is a Linux system administrator with a broad interest in things related to programming, architecture, and design. See: https://www.j15k.com/

License

Systemd cheat sheet by Jonas Jared Jacek is licensed under CC BY-SA 4.0.

This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, for noncommercial purposes only. To give credit, provide a link back to the original source, the author, and the license e.g. like this:

<p xmlns:cc="http://creativecommons.org/ns#" xmlns:dct="http://purl.org/dc/terms/"><a property="dct:title" rel="cc:attributionURL" href="https://www.ditig.com/systemd-cheat-sheet">Systemd cheat sheet</a> by <a rel="cc:attributionURL dct:creator" property="cc:attributionName" href="https://www.j15k.com/">Jonas Jared Jacek</a> is licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank" rel="license noopener noreferrer">CC BY-SA 4.0</a>.</p>

For more information see the Ditig legal page.

All Topics

Random Quote

“Obey standards unless you've a darn good reason.”

Alan Cooper  Software designer and programmerAbout Face, - IT quotes