How to Check the Status of a systemd Service?

Systemd is a system and service manager in modern Linux distributions. It’s responsible for starting and managing services, as well as monitoring the system’s state. To check the status of a systemd service, you can use several commands.

1. systemctl status

The systemctl status command allows you to track the current status of a service. For example, to find out the status of the Apache service, run the following command:

systemctl status apache2

After executing this command, you will receive information about the current state of the Apache service, as well as additional data such as the process PID, memory usage, etc.

2. systemctl is-active

The systemctl is-active command allows you to check if a service is active. For example, to check the activity of the SSH service, run the following command:

systemctl is-active ssh

If the service is active, you will get the response «active», if it is not active — «inactive».

3. systemctl is-enabled

The systemctl is-enabled command allows you to check whether a service is enabled for autostart. For example, to find out if the cron service is enabled for autostart, run the following command:

systemctl is-enabled cron

If the service is enabled for autostart, you will get the response «enabled», otherwise — «disabled».

Conclusion

Checking the status of systemd services is an important task for Linux administrators. Knowing the status and activity of services will help in system management and solving possible problems. Use the suggested commands for effective monitoring of services in the system.