Use Systemctl Status Command to Check Service Status
Learn how to check and understand the status of a systemd service using the systemctl command.
You'd find systemd in almost every popular distro and to control the services, you use the systemctl command.
And to check the current status of the service, you'd have to use the systemctl command in the following manner:
systemctl status <service-name>
As you can see, my Apache service is actively running.
Saw different status than active? or want to learn more about what different status means? Here you have it!
How to check service status using systemctl
Whether the systemd is good or bad is debatable, but it has surely made service management easy!
As all you have to do is use the systemctl command to start, stop, enable, and disable the service.
And same goes for checking the status of the service. Here, you'd have to use the status
flag with the systemctl command as shown:
systemctl status <service-name>
For example, if I want to check the status of the Apache service, then, I will use the following:
systemctl status apache2
As you can see, my Apache service is active.
Usually, it supports tab completion. So, you can hit the tab key to get suggestions for service names. Otherwise, you can always list systemd services and get the name.
But you can have multiple types of status. So let's have a look at what they mean.
Understanding systemctl states
active (running)
: Service is actively running in the background.active (exited)
: Indicates the service was meant to be executed one time or periodically. So the service did its job and then exit upon completion.active (waiting)
: It indicates the service is running but it is waiting to be triggered by some condition like a specific event.inactive
: Service is not currently running.enabled
: Service will be enabled at system boot time.disabled
: Service is disabled and won't be started at system boot.static
: It means the specific service can't be managed using systemd (or the systemctl command) and you'd need to have another init service or manage it manually.masked
: This means the service is masked and can't be stated directly using the systemctl command. This can be helpful when you want to prevent accidental starting of service.alias
: It indicates the service name is an alias and the service is a symlink pointing to another unit file.linked
: It indicates that the service or the unit file is symbolically linked to another unit file.
Other ways to use the systemctl command
Once you know what the status in systemctl means, let's have a quick look at how you can use the systemctl command to manage services.
Starting a service:
To start a service using the systemctl command, you'd have to use the start
flag with the systemctl command:
sudo systemctl start <service_name>
Stopping a service:
If you want to stop service immediately, you'd have to use the stop
flag with the systemctl command as shown:
sudo systemctl stop <service_name>
Enable service (starts the service from system boot automatically):
If you want to start the service automatically from the system boot, you'd have to execute the systemctl command with the enable
flag:
sudo systemctl enable <service_name>
Disable service (stops the service from system boot):
If you enabled the service, stopping it won't give you a permanent effect, and in that case, you'd have to disable the service:
sudo systemctl disable <service_name>
Next: Create your own systemd service
Want to create your own service and have no idea how to do it? Don't worry. We made a detailed guide that will walk you through how to create the systemd service:
I hope you will find this guide helpful.
A software engineer who loves to tinker with hardware till it gets crashed. While reviving my crashed system, you can find me reading literature, manga, or watering my plants.