• An Introduction to Managing a Linux Server with system
  • An Introduction to Managing a Linux Server with system
  • An Introduction to Managing a Linux Server with system
  • An Introduction to Managing a Linux Server with system
  • An Introduction to Managing a Linux Server with system

An Introduction to Managing a Linux Server with system

Systemd is 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 comprised 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.

Note:
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 re-started 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 the 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/multi-user.target.wants/httpd.service 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/multi-user.target.wants/httpd.service.
  • 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 test.example.com systemd[1]: Starting Apache web server managed ....
    Jan 26 13:32:15 test.example.com systemd[1]: PID file /run/apache2/httpd.pid not....
    Jan 26 13:32:15 test.example.com 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)

NAME
       systemctl - Control the systemd system and service manager

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

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

Add your review

Your email address will not be published. Required fields are marked *