How to view status of a service on Linux using systemctl

On Linux systems using systemd, you can use the “systemctl” command to view the status of a service. The basic syntax for the command is:

systemctl status [service_name]

For example, to check the status of the Apache web server, you can use the command:

systemctl status httpd

This command will return the current status of the service, including whether it is running, inactive, or failed, and the process ID of the service.

You can also use the option “–all” or “-a” to list all services, including inactive ones:

systemctl list-units --all

Additionally, you can use the option “–type=service” to filter only services.

systemctl list-units --type=service

The output will show the status of the service, like whether it’s active, inactive, or failed, the load order, and the dependencies of the service.

You can also use the command “systemctl is-active [service_name]” to check if the service is running, “systemctl is-enabled [service_name]” to check if the service is enabled to start at boot time, and “systemctl show [service_name]” to show the service’s properties and current status in more detail.

It’s important to note that the service name may vary depending on the Linux distribution. It’s recommended to check the service’s name on the service’s documentation or by using the command “systemctl list-units –all” to list all the services and their names.

Leave a Comment