SYSTEMCTL Commands Cheatsheet — Essential Reference
systemctl is a command-line utility used to control the systemd system and service manager. It allows you to manage services, check their status, and control the system's power state.
Master SYSTEMCTL with Top Reference Books
Level up your DevOps skills. Find the best guide books and cheatsheet references for your engineering stack.
Commands
| Command | Description | Example |
|---|---|---|
systemctl start <service_name> |
Starts a specified service immediately. | systemctl start apache2 |
systemctl stop <service_name> |
Stops a specified service immediately. | systemctl stop nginx |
systemctl restart <service_name> |
Restarts a specified service. | systemctl restart sshd |
systemctl enable <service_name> |
Enables a service to start automatically at boot. | systemctl enable docker |
systemctl disable <service_name> |
Disables a service from starting automatically at boot. | systemctl disable cups |
systemctl status <service_name> |
Shows the current status of a service, including whether it's running, enabled, and recent logs. | systemctl status systemd-resolved |
systemctl is-active <service_name> |
Checks if a service is currently active (running). Returns 0 for active, 1 for inactive. | systemctl is-active mariadb |
systemctl is-enabled <service_name> |
Checks if a service is enabled to start at boot. Returns 0 for enabled, 1 for disabled. | systemctl is-enabled cron |
systemctl list-units --type=service |
Lists all loaded service units. | systemctl list-units --type=service |
systemctl list-unit-files --type=service |
Lists all installed service unit files and their enable/disable status. | systemctl list-unit-files --type=service |
systemctl poweroff |
Shuts down and powers off the system. | systemctl poweroff |
systemctl reboot |
Reboots the system. | systemctl reboot |
systemctl suspend |
Suspends the system (puts it to sleep). | systemctl suspend |
systemctl hibernate |
Hibernates the system (saves state to disk and powers off). | systemctl hibernate |
systemctl get-default |
Shows the default target (runlevel) that the system boots into. | systemctl get-default |
systemctl set-default <target_name> |
Sets the default target (runlevel) for the system. | systemctl set-default multi-user.target |
systemctl cat <service_name> |
Displays the content of a service unit file. | systemctl cat sshd |
systemctl edit <service_name> |
Opens an editor to create or modify an override file for a service. | systemctl edit nginx |
Pro Tips
- Use `systemctl --failed` to quickly see all failed units.
- For detailed logs of a service, combine with `journalctl -u <service_name>`.
- Always use `sudo` when managing system services with `systemctl`.
- To reload systemd manager configuration after creating or modifying unit files, run `systemctl daemon-reload`.
Frequently Asked Questions
What is systemctl used for?
systemctl is the primary command-line tool for controlling the systemd system and service manager. It's used to manage services (start, stop, enable, disable), check their status, and control the system's power state (reboot, shutdown, suspend).
How do I install systemctl?
systemctl is an integral part of the systemd init system, which is the default for most modern Linux distributions (e.g., Ubuntu, Debian, Fedora, CentOS, Arch Linux). You typically don't need to install it separately; it comes pre-installed with your operating system if it uses systemd.