When working with services in RHEL 7, you can check if a service is currently running with the is-active option or enabled at boot time with the is-enabled option. But it is more difficult to know if the unit file is located in /usr/lib/systemd/system or /etc/systemd/system in the case of a custom service. It is also not obvious to know when the service was started or to get some CGroup information.
The systemctl status command brings all this information and even more.
Let’s take the httpd example and run the following command:
# systemctl status httpd httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled) Active: active (running) since Tue 2015-04-21 11:48:23 CEST; 24h ago Main PID: 2446 (httpd) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service └─2446 /usr/sbin/httpd -DFOREGROUND └─2447 /usr/sbin/httpd -DFOREGROUND └─2448 /usr/sbin/httpd -DFOREGROUND └─2449 /usr/sbin/httpd -DFOREGROUND └─2450 /usr/sbin/httpd -DFOREGROUND └─2451 /usr/sbin/httpd -DFOREGROUND └─2452 /usr/sbin/httpd -DFOREGROUND Apr 21 11:48:23 server1.example.com systemd: Starting The Apache HTTP Ser.... Apr 21 11:48:23 server1.example.com systemd: Started The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full.
The first line gives you a description of the service. You then learn that Systemd loaded the unit file from /usr/lib/systemd/system/httpd.service and the service is not enabled at boot time (disabled).
You next learn that the service has been running (active) for 24 hours and when was exactly the launch date.
The following line provides the Process ID.
In the case of the httpd service, you even get a quick activity report.
Then, the CGroup information is shown with the list of the child processes.
Finally, an extract from the journal is displayed with the most useful events.
Even though at first sight the systemctl status command seems to display too many lines, when you look at it, everything is there!