How to see enabled services that have been stopped [systemd]
from to on 28 Nov 2023 04:13

Someone tell me if there is a better way to do this, but I don’t see how.

I needed a way to see which services I have enabled that I have manually stopped.

There oddly isn’t a way to do this in one command, so I had to take the output of list-unit-files ‘enabled’, and use that to filter for ‘list-units’. The command is here:

alias sysstop=‘systemctl list-units --state=failed,dead,exited $( systemctl list-unit-files --state=enabled --type=service | awk “/.*\.service/ {print }” )’

So now I can remember that I need to restart mariadb and nginx at some point:

$ sysstop
  UNIT                                 LOAD   ACTIVE   SUB    DESCRIPTION                                             
  blueman-mechanism.service            loaded inactive dead   Bluetooth management mechanism
  mariadb.service                      loaded inactive dead   MariaDB 11.2.2 database server
  NetworkManager-wait-online.service   loaded active   exited Network Manager Wait Online
  nginx.service                        loaded inactive dead   A high performance web server and a reverse proxy server
  systemd-homed-activate.service       loaded active   exited Home Area Activation
  systemd-networkd-wait-online.service loaded active   exited Wait for Network to be Configured

My other aliases are here, in case anyone finds these helpful. I use them frequently myself.

alias sysdis='systemctl list-unit-files --type=service --state=disabled'
alias sysdisuser='systemctl list-unit-files --type=service --state=disabled --user'
alias sysen='systemctl list-unit-files --type=service --state=enabled'
alias sysenuser='systemctl list-unit-files --type=service --state=enabled --user'
alias sysfail='systemctl list-units --type=service --state=failed'
alias sysrun='systemctl list-units --type=service --state=running'
alias sysrunuser='systemctl list-units --type=service --state=running --user'
alias sysstatic='systemctl list-units --type=service --state=static'

#linux on 28 Nov 2023 05:20 next collapse

Don’t you start a service with system tl servicename? on 28 Nov 2023 07:44 collapse


systemctl start [servicename]

But I wanted to see what I have stopped and not started again on 28 Nov 2023 13:07 collapse

OK, that’s nothing I can help you with. on 28 Nov 2023 06:59 next collapse

Can’t you do systemctl status [service] to check that? on 28 Nov 2023 07:42 next collapse

That's only for a single service, not really what OP seems to be asking for on 28 Nov 2023 07:43 collapse

Only if you know what the [service] is. In my case, I’m prone to forgetting so this way I can see what should be running but isn’t on 28 Nov 2023 11:33 collapse

systemctl status | grep stopped on 28 Nov 2023 18:43 collapse

I think you’re thinking of

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

status gives the state of the system and a cgroup tree