Operations 8 min read

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.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux Services: Essential systemctl Commands Explained

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 sshd

Check Service Status

View whether a service is active with:

root@localhost~# systemctl status firewalld

Enable 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.service

Check if a service is enabled:

root@localhost~# systemctl is-enabled httpd.service

The 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 service

List all active targets (run‑level equivalents):

root@localhost~# systemctl list-units -t target

Manage System Power

Power off the machine: root@localhost~# systemctl poweroff Reboot the machine: root@localhost~# systemctl reboot Hibernate the machine:

root@localhost~# systemctl hibernate

Remote 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.target

Show the current default target:

root@localhost~# systemctl get-default
multi-user.target

Set the default target to graphical mode:

root@localhost~# systemctl set-default graphical.target

Other 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.901s

List services ordered by their startup time: root@localhost~# systemd-analyze blame hostnamectl displays and changes the system’s hostname:

root@localhost~# hostnamectl

Conclusion

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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

OperationsLinuxService Managementsystemdsystemctljournalctlsystemd-analyze
Liangxu Linux
Written by

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.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.