How to Check Service Status in Linux Ubuntu 18.04

Posted on

Introduction

It is a simple article showing how to check the status of a certain service in Linux Ubuntu 18.04. Basically, there are lots of services available in an operating system. Not to mention a Linux operating system which in this context it is a Linux Ubuntu 18.04. There are several steps for checking the status of a specific service. The following are those steps :

In order to check for the service status, the first step is to search that specific service. Just execute a certain command for to list all the available services in that operating system that match with part of the service name. The following is that command to display that specific service :

service --status-all | grep service_name

The following is the example to search that specific service. For an example, in this context the service name is ‘apache2’. The following is the output generated after executing the above command in the operating system :

root@hostname ~# service --status-all | grep apache2
 [ - ]  apache2
root@hostname ~# 

Another one for searching a specific service is in the following pattern :

systemctl -l --type service --all | grep service_name

The following is the execution of the above command pattern using ‘apache2’ as an example of the searched service :

root@hostname ~# systemctl -l --type service --all | grep apache2
● apache2.service                                       loaded    active   running  The Apache HTTP Server                                                          
root@hostname ~# 

In the above command execution, the status of the service is actually available. Without having to check further, a short information about the status is already there in the above output.

 

 

Checking the service status in detail

Next, if there is a need for specific and detail about the status of the service, just execute according to the following command pattern :

systemctl status service_name

So, if apache2 is an example to check the status of it, the following is an output of the generated :

root@hostname ~# systemctl status apache2
● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: active (running) since Sat 2019-08-10 12:01:58; 9s ago
  Process: 19873 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
 Main PID: 19890 (apache2)
    Tasks: 26 (limit: 4915)
   CGroup: /system.slice/apache2.service
           ├─19890 /usr/sbin/apache2 -k start
           ├─19894 (wsgi:keystone-pu -k start
           ├─19895 (wsgi:keystone-pu -k start
           ├─19896 (wsgi:keystone-pu -k start
           ├─19900 (wsgi:keystone-pu -k start
           ├─19901 (wsgi:keystone-pu -k start
           ├─19902 /usr/sbin/apache2 -k start
           ├─19903 /usr/sbin/apache2 -k start
           ├─19904 /usr/sbin/apache2 -k start
           ├─19905 /usr/sbin/apache2 -k start
           └─19906 /usr/sbin/apache2 -k start

Aug 10 12:01:56 hostname systemd[1]: Starting The Apache HTTP Server...
Aug 10 12:01:58 hostname systemd[1]: Started The Apache HTTP Server.
root@hostname ~# 

Referring to the output generated above, the service status is currently active or running. The information is not in the short form, but it has lots of additional information regarding on the service.   It informs the status, the id process of the service and many more.

Leave a Reply