brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: systemctl list-units can show only what is running right now

Systemctl
~/tips/tip-systemctl-list-running-services

systemctl list-units --type=service --state=running

Get a clean list of what is active on a machine right now.

When I log in to a box I do not know well, I want to see what it is actually doing. A filtered unit list gives that in one screen.

systemctl list-units --type=service --state=running

Each line shows the unit, its load and activity state, and a short description. No sudo needed. Without the filters you also get mounts, devices, sockets and a lot of other units, which buries the part you care about.

The filters take comma separated values, so you can ask for more than one state or type:

systemctl list-units --type=service,socket --state=running,listening

For a count or for a script, switch off the pager and the header lines:

systemctl list-units --type=service --state=running --no-pager --legend=false | wc -l

Compare the list on a fresh install with the list a few months later and you will spot things that were added along the way.

This shows the present moment only. A service that starts on demand or runs from a timer once a day is missing when it is idle, and a service that is enabled but crashed is not here either. For the question of what starts at boot, look at unit files instead.

Further reading: systemctl man page

More Systemctl tips sudo systemctl daemon-reload systemctl -H [email protected] status nginx sudo systemctl reboot --firmware-setup systemctl list-jobs sudo systemctl try-restart nginx.service All Systemctl tips (9) All topics

Link