Listing Linux systemd Services with Systemctl
On most modern, mainstream Linux distributions you can list services with the following systemd command.
List active services by default:
sudo systemctl list-units --type service
List all services and not just active services use this command:
sudo systemctl list-units --type service --all
Check the status of a service ( nginx for example ):
sudo systemctl status nginx.service
Same but you don’t need the extension and usually don’t need sudo just to check status:
systemctl status nginx
Just check if it is active or not:
systemctl is-active nginx
Loaded | loaded status, path to unit file |
Active | status and how long it has been running |
Docs | man page info |
Process | Process info: binary, args, etc |
Main PID | Top level PID for service |
Tasks | Task count and task limit |
Memory | Memory usage info |
CGroup | Control group info |
What is a service?
A service is basically just a program that runs contiously in the background. They can perform background or maintenance tasks. They can also be used as servers to serve data ( ex. web servers or database servers ).
Examples of a service
A few examples of services might be either Apache or Nginx web servers. MySQL or MongoDB database servers. Other examples might include pulseaudio or pipe-wire that run in the background and manage audio for a desktop system.
What is systemd?
Systemd is a collection of system components that are used to manage some Linux systems. It can be used to control may different aspects of a system from services to networking to logging. It is best known for managing services for the system. It allows for managing service dependencies and stating services in parallel when needed. It is also used to watch and relaunch services when they fail.
Systemd Unit Files
These files are text files in ini format. They have a “.service” extension. They define servcies and their attributes.