Linux Commands

How to Use systemctl status Command

The systemctl is a command line utility used to monitor and manage the systemd services. Where systemd is the service manager used in all modern Linux distributions. In this guide, I will be going through how to use the systemctl command with a status option to check the status of various systemd services on Linux.

Note: The instructions and commands given in this tutorial are executed on Ubuntu. However, the commands will work without any error on Linux distributions that come with systemd init system.

How to Use systemctl status Command

The systemctl is available in all Linux distributions with a systemd service manager. Therefore, it is not necessary to install any specific package for it.

The systemctl has various options and one of the widely used options is status. The systemctl status option is used to find the current runtime status of a unit or whole system.

In the systemd, the unit is referred to as an object that executes a particular task. A unit can be a service, device, or socket. To list all units, use the systemctl -t help command.

Note that the status function only provides information on the units that are currently in the memory or released from the memory recently. Information from the previous session will not appear using this function.

The general syntax to use the systemctl status command is given below:

systemctl status [unit_name]

As discussed earlier, a unit can be a service, socket, or device.

For example, to find the status of the sshd which is a daemon service, use the command mentioned below.

systemctl status sshd

The above out presents the data in the human-readable form. You get the active and load status. Moreover, this command also lists the unit’s PID, memory, and CPU usage.

Loaded: It shows that the unit is loaded in the memory.

Loaded States
error If the file is not loaded to memory properly
not-found If the service does not exist
bad-setting If the unit file is not parsed properly
masked If the unit file is masked (disabled)

This state also shows the path of the unit which is stored in the /lib/systemd/system and the enablement state of the unit. The enablement can be enabled, disabled, and static.

Enablement States
Enabled The unit is enabled while booting
Disabled The unit is not enabled while booting
Static The unit cannot be enabled on Linux

Active: It shows the active state with various indications.

Active The unit is active (started, bound, plugged) and running
Inactive The unit is not active
Activating The unit is in the state of activating
Deactivating The unit is in the state of deactivating
Failed The unit fails to activate due to crash, error of timeout

Docs: It provides a command for documentation of the unit.

Main PID: It shows the process of the unit.

Tasks: A task is a unit of work done by a unit, and the limit is the maximum number of tasks that a particular unit can perform.

Memory: It indicates the memory usage of the unit.

CPU: It shows the CPU usage by the unit.

CGroup: Also called Control Group is a kernel feature that controls the resources such as RAM and CPU taken by the units.

State Indications of systemctl status Command

The systemctl status output shows various indications about the unit state. If it is active then a green dot will appear, if it is inactive then a white dot will be shown in the output.

Erred or failed units will be shown in the form of a red cross. If the service is in the reloading state, then it will be shown as a green clockwise arrow.

Limitation of systemctl status Command

The systemctl status command does not necessarily provide you with the most accurate output about whether the unit was loaded on boot or not. Because the systemd loads the unit when it is required, so if you try to find the status of the un-loaded unit or a unit that was loaded and removed from the memory after boot, then the command will show an error. So, you will not get the information of a unit that is present but released to the memory after its operation is completed.

How to Exit systemctl status Command

The terminal appears to freeze up after executing the systemctl status command. This is because of the paginated output of the command.

To exit the systemctl status, there are multiple methods.

  • Adding –no-pager after the command
  • Using the q key
  • Using the Ctrl+C

Adding the –no-pager after the systemctl status command and it will automatically remove the pagination.

systemctl status sshd --no-pager

Or just press the q key to exit the systemctl status command.

Conclusion

The systemctl status command is used to check the statuses of systemd units. On Linux, the units can be a device, socket, or service. The units can have states like active, inactive, dead, or failed. This command also provides information like unit load status, process ID, memory, and CPU usage. However, the systemctl status command is not useful to find the load status of a unit. Because a unit can be unloaded by systemd after its operation is completed.

About the author

Sam U

I am a professional graphics designer with over 6 years of experience. Currently doing research in virtual reality, augmented reality and mixed reality.
I hardly watch movies but love to read tech related books and articles.