Blog

Basic systemd Commands

Learn essential systemd commands to manage services in modern Linux distributions. This guide covers starting, stopping, and checking service statuses.

Dmytro
systemd Linux service management command line system administration

Basic systemd Commands

System administrators are aware that almost all recent versions of popular Linux distributions use a new system - systemd - rather than the traditional System V init. Debates continue about whether systemd is superior to traditional solutions, but there are no alternatives in modern systems, so it’s important to understand the basic functions and commands.

The task of initd and systemd is to start up after the system kernel and then sequentially launch other necessary services and utilities. Below are the main commands for working with services.

It’s worth noting that it’s common practice to use a suffix when specifying the required module name. This is not mandatory - calling systemctl status mariadb and systemctl status mariadb.service will yield the same result - but is recommended; there are other suffixes like .socket, .device, .mount, and so on.

Starting, Restarting, and Stopping Services:

systemctl start app.service
systemctl stop app.service
systemctl restart app.service

For example, to restart nginx:

systemctl restart nginx.service

If a service supports configuration updates without a full restart, you can use the following command:

systemctl reload app.service

There’s a convenient feature - if you’re unsure whether a service supports configuration updates without restarting, you can run the command reload-or-restart:

systemctl reload-or-restart app.service

In this case, if configuration updates are supported, the service will be reloaded; if not, it will be completely restarted. Convenient!

Checking Service Status:

You can check the status of a service using systemctl status. For example:

systemctl status mariadb
● mariadb.service - MariaDB database server
 Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
 Active: active (running) since Sun 2017-04-09 11:50:05 EEST; 3h 29min ago
 Main PID: 12241 (mysqld_safe)
 CGroup: /system.slice/mariadb.service
 ├─12241 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
 └─12578 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/m...  

If a service should be started at boot time, it should be explicitly specified:

systemctl enable app.service

Conversely, if you need to prevent a particular service from starting, use:

systemctl disable app.service

If you want a list of all active services, you can run the command:

systemctl list-units --type=service
UNIT LOAD ACTIVE SUB DESCRIPTION
 auditd.service loaded active running Security Auditing Service
 chronyd.service loaded active running NTP client/server
 crond.service loaded active running Command Scheduler
 ....

Systemd can also be used to reboot, power off the system, and to enter single-user mode:

systemctl reboot
systemctl poweroff
systemctl rescue

We’ve only covered a part of systemd’s capabilities. Want to know more? Feel free to check out the links below:

Need Help?

Our support team is available 24/7 to assist you with any questions or issues.

Contact Support