An Introduction to Managing a Linux Server with systemd

Posted on by Helpful Humans of Liquid Web
Reading Time: 2 minutes

Systemd is an init system used by several common Linux Distributions which has gained popularity since 2015. A Linux init system is the first process or daemon started on a system after the initial boot process, and manages services, daemons, and other system processes. Systemd is composed of unit files that contain the initialization instructions for the daemons which it controls. While many portions of a system can be managed with systemd, this article will focus on managing services.

How to Manage a Linux Server with systemd

To control services with systemd, the systemctl command is used. Let’s go over how to start, stop, restart, enable and disable, and check the status of a service. We’ll use the Apache Service, known as httpd on RedHat Based Linux distributions as an example.

Unless there is a failure running some of these commands, they will not output any results, this is expected. Commands expected to have output will be noted.
  • Starting:
    This will only start a service one time, if you want the service to be started on boot, see the “Enable on Boot” command below.
    systemctl start httpd
  • Stopping:
    This will only stop a service one time, if you want the service to not be restarted on boot, see the “Disable on Boot” command below.
    systemctl stop httpd
  • Restart:
    Fully stops and starts a service:
    systemctl restart httpd
  • Reload:
    Reloads a service’s configuration without causing the service to restart. Not all services accept that reload command.
    systemctl reload httpd
  • Enable on Boot:
    This will set the specified service to start up every time a system is booted up.
    systemctl enable httpdExample output:

    Created symlink from /etc/systemd/system/ to /etc/systemd/system/httpd.service.
  • Disable on Boot:
    This will set the specified service to not start up every time a system is booted up.
    systemctl disable httpdExample output:

    Removed symlink /etc/systemd/system/
  • Check Status:
    systemctl status httpd

    Example output:

    ● httpd.service - Apache web server managed by cPanel EasyApache
       Loaded: loaded (/etc/systemd/system/httpd.service; enabled; vendor preset: disabled)
       Active: active (running) since Fri 2018-01-26 13:32:15 EST; 20h ago
     Main PID: 2988 (httpd)
       CGroup: /system.slice/httpd.service
               ├─ 2988 /usr/sbin/httpd -k start
               ├─30142 /usr/sbin/httpd -k start
               ├─30143 /usr/local/cpanel/3rdparty/bin/perl /usr/local/cpanel/bin/leech...
               ├─30144 /usr/sbin/httpd -k start
               ├─30145 /usr/sbin/httpd -k start
               ├─30219 /usr/sbin/httpd -k start
               ├─30220 /usr/sbin/httpd -k start
               └─30221 /usr/sbin/httpd -k start
    Jan 26 13:32:15 systemd[1]: Starting Apache web server managed ....
    Jan 26 13:32:15 systemd[1]: PID file /run/apache2/ not....
    Jan 26 13:32:15 systemd[1]: Started Apache web server managed b....
    Hint: Some lines were ellipsized, use -l to show in full.

One of the main points of this output are the third line, in this case showing Active: active (running), this shows that the service is presently started and active.

More Information:

More information on using systemctl, and other portions of systemd can be found in several Linux manual pages, primarily systemctl(1).

Here’s a short example of the command to view the manual page, and the first few lines of that page:
man 1 systemctl

SYSTEMCTL(1)                  systemctl                 SYSTEMCTL(1)

       systemctl - Control the systemd system and service manager

       systemctl [OPTIONS...] COMMAND [NAME...]

       systemctl may be used to introspect and control the state of
       the "systemd" system and service manager. Please refer to
       systemd(1) for an introduction into the basic concepts and
       functionality this tool manages.

About the Author: Helpful Humans of Liquid Web

Have Some Questions?

Our Sales and Support teams are available 24 hours by phone or e-mail to assist.


Latest Articles

What is an Intrusion Prevention System (IPS)?

Read Article

Premium Business Email Pricing FAQ

Read Article

What is the Fortran Programming Language?

Read Article

Microsoft Exchange Server Security Update

Read Article

How to Monitor Your Server in WHM

Read Article