Base Service Commands

This article describes how to manage services by using systemd.

Introduction

Many modern Linux® operating systems available at Rackspace, such as Centos® 7 and later and Ubuntu® 16.04,
adopted systemd as a system manager. So you might want to know the ins and outs of how to use it to manage your applications.

Use systemctl

When you use systemd to manage applications, you use the command systemctl. The following sections
describe several of this command's functions.

Start and stop services

Use the command systemctl start application.service to start the application and the command systemctl stop application.service to stop the application. If you don't know if a service is running, you can use the
command systemctl status application.service to check the status, as shown in the following example:

[root@localhost ~]# systemctl status httpd.service
   httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd(8)
       man:apachectl(8)
[root@localhost ~]# ~# systemctl status apache2.service
○ apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Wed 2026-07-22 19:32:44 IST; 2s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 1750 ExecStop=/usr/sbin/apachectl graceful-stop (code=exited, status=0/SUCCESS)
   Main PID: 1481 (code=exited, status=0/SUCCESS)
        CPU: 81ms
[root@localhost ~]# systemctl start httpd.service OR [root@localhost ~]# systemctl enable --now httpd.service
[root@localhost ~]# systemctl start apache2.service OR 


[root@localhost ~]# systemctl enable --now apache2.service
Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable apache2
[root@localhost ~]# systemctl status httpd.service
  httpd.service - The Apache HTTP Server
  Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
  Active: active (running) since Sun 2020-05-24 01:30:02 UTC; 1s ago
    Docs: man:httpd(8)
       man:apachectl(8)
 Main PID: 16117 (httpd)
 Status: "Processing requests..."
 CGroup: /system.slice/httpd.service
       ├─16117 /usr/sbin/httpd -DFOREGROUND
       ├─16118 /usr/sbin/httpd -DFOREGROUND
       ├─16119 /usr/sbin/httpd -DFOREGROUND
       ├─16120 /usr/sbin/httpd -DFOREGROUND
       ├─16121 /usr/sbin/httpd -DFOREGROUND
       └─16122 /usr/sbin/httpd -DFOREGROUND

May 24 01:30:02 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
May 24 01:30:02 localhost.localdomain httpd[16117]: AH00558: httpd: Could not reliably determine
the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' 
directive globally to suppress this message
May 24 01:30:02 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
[root@localhost ~]#
[root@localhost ~]# systemctl status apache2.service
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2026-07-22 19:34:28 IST; 36s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 2021 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 2025 (apache2)
      Tasks: 55 (limit: 18848)
     Memory: 5.7M
        CPU: 30ms
     CGroup: /system.slice/apache2.service
             ├─2025 /usr/sbin/apache2 -k start
             ├─2026 /usr/sbin/apache2 -k start
             └─2027 /usr/sbin/apache2 -k start

Jul 22 19:34:28 AAD-70TSYB4 systemd[1]: Starting The Apache HTTP Server...
Jul 22 19:34:28 AAD-70TSYB4 systemd[1]: Started The Apache HTTP Server.
[root@localhost ~]#

Restart or reload services

Restarting and reloading a service are two separate things with systemd.

When you run the command systemctl restart application.service, the specified service restarts. If the service is in a stopped state, it starts.

When you run the command systemctl reload application.service, the configuration of the specified service reloads. For example, if you make any changes to an Apache® virtual host (vhost) and you want those changes to go live without stopping Apache, you reload the service. The new configurations take place without interrupting the service.

Enable and disable services

If you want a specific service to start when the server is booted up, run the command systemctl enable application.service. If you want to make sure a service does not start when the server boots up, run the command systemctl disable application.service.

:~# systemctl -h
systemctl [OPTIONS...] COMMAND ...

Query or send control commands to the system manager.

Unit Commands:
  list-units [PATTERN...]             List units currently in memory
  list-sockets [PATTERN...]           List socket units currently in memory,
                                      ordered by address
  list-timers [PATTERN...]            List timer units currently in memory,
                                      ordered by next elapse
  is-active PATTERN...                Check whether units are active
  is-failed PATTERN...                Check whether units are failed
  status [PATTERN...|PID...]          Show runtime status of one or more units
  show [PATTERN...|JOB...]            Show properties of one or more
                                      units/jobs or the manager
  cat PATTERN...                      Show files and drop-ins of specified units
  help PATTERN...|PID...              Show manual for one or more units
  list-dependencies [UNIT...]         Recursively show units which are required
                                      or wanted by the units or by which those
                                      units are required or wanted
  start UNIT...                       Start (activate) one or more units
  stop UNIT...                        Stop (deactivate) one or more units
  reload UNIT...                      Reload one or more units
  restart UNIT...                     Start or restart one or more units
  try-restart UNIT...                 Restart one or more units if active
  reload-or-restart UNIT...           Reload one or more units if possible,
                                      otherwise start or restart
  try-reload-or-restart UNIT...       If active, reload one or more units,
                                      if supported, otherwise restart
  isolate UNIT                        Start one unit and stop all others
  kill UNIT...                        Send signal to processes of a unit
  clean UNIT...                       Clean runtime, cache, state, logs or
                                      configuration of unit
  freeze PATTERN...                   Freeze execution of unit processes
  thaw PATTERN...                     Resume execution of a frozen unit
  set-property UNIT PROPERTY=VALUE... Sets one or more properties of a unit
  bind UNIT PATH [PATH]               Bind-mount a path from the host into a
                                      unit's namespace
  mount-image UNIT PATH [PATH [OPTS]] Mount an image from the host into a
                                      unit's namespace
  service-log-level SERVICE [LEVEL]   Get/set logging threshold for service
  service-log-target SERVICE [TARGET] Get/set logging target for service
  reset-failed [PATTERN...]           Reset failed state for all, one, or more
                                      units
Unit File Commands:
  list-unit-files [PATTERN...]        List installed unit files
  enable [UNIT...|PATH...]            Enable one or more unit files
  disable UNIT...                     Disable one or more unit files
  reenable UNIT...                    Reenable one or more unit files
  preset UNIT...                      Enable/disable one or more unit files
                                      based on preset configuration
  preset-all                          Enable/disable all unit files based on
                                      preset configuration
  is-enabled UNIT...                  Check whether unit files are enabled
  mask UNIT...                        Mask one or more units
  unmask UNIT...                      Unmask one or more units
  link PATH...                        Link one or more units files into
~]# systemctl -h
systemctl [OPTIONS...] COMMAND ...

Query or send control commands to the system manager.

Unit Commands:
  list-units [PATTERN...]             List units currently in memory
  list-automounts [PATTERN...]        List automount units currently in memory,
                                      ordered by path
  list-sockets [PATTERN...]           List socket units currently in memory,
                                      ordered by address
  list-timers [PATTERN...]            List timer units currently in memory,
                                      ordered by next elapse
  is-active PATTERN...                Check whether units are active
  is-failed PATTERN...                Check whether units are failed
  status [PATTERN...|PID...]          Show runtime status of one or more units
  show [PATTERN...|JOB...]            Show properties of one or more
                                      units/jobs or the manager
  cat PATTERN...                      Show files and drop-ins of specified units
  help PATTERN...|PID...              Show manual for one or more units
  list-dependencies [UNIT...]         Recursively show units which are required
                                      or wanted by the units or by which those
                                      units are required or wanted
  start UNIT...                       Start (activate) one or more units
  stop UNIT...                        Stop (deactivate) one or more units
  reload UNIT...                      Reload one or more units
  restart UNIT...                     Start or restart one or more units
  try-restart UNIT...                 Restart one or more units if active
  reload-or-restart UNIT...           Reload one or more units if possible,
                                      otherwise start or restart
  try-reload-or-restart UNIT...       If active, reload one or more units,
                                      if supported, otherwise restart
  isolate UNIT                        Start one unit and stop all others
  kill UNIT...                        Send signal to processes of a unit
  clean UNIT...                       Clean runtime, cache, state, logs or
                                      configuration of unit
  freeze PATTERN...                   Freeze execution of unit processes
  thaw PATTERN...                     Resume execution of a frozen unit
  set-property UNIT PROPERTY=VALUE... Sets one or more properties of a unit
  bind UNIT PATH [PATH]               Bind-mount a path from the host into a
                                      unit's namespace
  mount-image UNIT PATH [PATH [OPTS]] Mount an image from the host into a
                                      unit's namespace
  service-log-level SERVICE [LEVEL]   Get/set logging threshold for service
  service-log-target SERVICE [TARGET] Get/set logging target for service
  reset-failed [PATTERN...]           Reset failed state for all, one, or more
                                      units
Unit File Commands:
  list-unit-files [PATTERN...]        List installed unit files
  enable [UNIT...|PATH...]            Enable one or more unit files
  disable UNIT...                     Disable one or more unit files
  reenable UNIT...                    Reenable one or more unit files
  preset UNIT...                      Enable/disable one or more unit files
                                      based on preset configuration
  preset-all                          Enable/disable all unit files based on
                                      preset configuration
  is-enabled UNIT...                  Check whether unit files are enabled
  mask UNIT...                        Mask one or more units


Did this page help you?