Master Linux Services: Essential systemctl Commands Explained
This guide walks you through using the systemctl tool on modern Linux distributions to start, stop, restart, reload, enable, disable, and query services, manage system power, work with targets, handle remote hosts, and leverage related utilities like journalctl, systemd-analyze, and hostnamectl.
Introduction
Systemctl is the primary command‑line interface for interacting with systemd, the init system used by most modern Linux distributions such as Ubuntu, Debian, Fedora, and Red Hat.
Start, Stop, Restart, and Reload Services
To start a service, use systemctl start [service‑name]. Example: root@localhost~# systemctl start firewalld Stopping a service uses systemctl stop [service‑name]: root@localhost~# systemctl stop firewalld Restarting a service: root@localhost~# systemctl restart firewalld Reloading a service’s configuration without a full restart (e.g., sshd) uses systemctl reload [service‑name]:
root@localhost~# systemctl reload sshdCheck Service Status
View whether a service is active with:
root@localhost~# systemctl status firewalldEnable or Disable Services at Boot
Enable a service to start automatically on boot: root@localhost~# systemctl enable httpd.service Disable it:
root@localhost~# systemctl disable httpd.serviceCheck if a service is enabled:
root@localhost~# systemctl is-enabled httpd.serviceThe command returns enabled or disabled.
List Units, Services, and Targets
List all active units: root@localhost~# systemctl list-units List only active services:
root@localhost~# systemctl list-units -t serviceList all active targets (run‑level equivalents):
root@localhost~# systemctl list-units -t targetManage System Power
Power off the machine: root@localhost~# systemctl poweroff Reboot the machine: root@localhost~# systemctl reboot Hibernate the machine:
root@localhost~# systemctl hibernateRemote Management
All the above commands can be run against a remote host using the -H option (which specifies user@host), for example:
root@localhost~# systemctl status httpd -H [email protected]Targets and Runlevels
Systemd targets correspond to traditional SysV runlevels. The mapping is:
0 runlevel0.target, poweroff.target
1 runlevel1.target, rescue.target
2,3,4 runlevel2.target, runlevel3.target, runlevel4.target, multi-user.target
5 runlevel5.target, graphical.target
6 runlevel6.target, reboot.targetShow the current default target:
root@localhost~# systemctl get-default
multi-user.targetSet the default target to graphical mode:
root@localhost~# systemctl set-default graphical.targetOther Systemd Utilities
journalctl accesses the journald log system. Basic usage: root@localhost~# journalctl Show only the current boot’s messages: root@localhost~# journalctl -b Follow logs in real time (similar to tail -f): root@localhost~# journalctl -f systemd-analyze reports boot timing. Example output:
root@localhost~# systemd-analyze
Startup finished in 497ms (kernel) + 1.836s (initrd) + 6.567s (userspace) = 8.901sList services ordered by their startup time: root@localhost~# systemd-analyze blame hostnamectl displays and changes the system’s hostname:
root@localhost~# hostnamectlConclusion
The article covered the most common systemctl commands for managing services, boot targets, power states, remote hosts, and related tools, providing a practical reference for Linux system administrators.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
