How can I list all enabled
services from systemctl
?
I know running systemctl
command by itself lists all services, but I would like to only get the enabled
ones.
How can I list all enabled
services from systemctl
?
I know running systemctl
command by itself lists all services, but I would like to only get the enabled
ones.
systemctl list-unit-files | grep enabled
will list all enabled ones.
If you want which ones are currently running, you need systemctl | grep running
.
Use the one you're looking for. Enabled, doesn't mean it's running. And running doesn't mean it's enabled. They are two different things.
Enabled means the system will run the service on the next boot. So if you enable a service, you still need to manually start it, or reboot and it will start.
Running means it's actually running right now, but if it's not enabled, it won't restart when you reboot.
systemctl | grep running
do not list anything to me! Even if something is running is only listed as for his status like: enabled, disabled, masked, static
– Cirelli94
Apr 13 '17 at 10:34
systemctl | grep -E 'running.*active|active.*running' | grep mys
– Eric Hepperle - CodeSlayer2010
Apr 20 '17 at 16:01
systemctl
with no other options shows an output where the 4th column states if something is running/failed/exited etc. Are you sure you're running Ubuntu 16.04?
– Delorean
Apr 20 '17 at 18:16
systemctl | grep mysql
to see if it's running.
– Delorean
Apr 20 '17 at 18:18
systemctl list-unit-files
does not list ALL serivces. For example, it does not list tinc
, even though tinc is enabled. Maybe systemctl list-unit-files
only lists services that have unit files? But fails to lists any services that might be enabled via legacy sysv style init scripts?
– mpb
Dec 17 '17 at 22:42
sshd.service
, but the unit is actually called ssh.service
. Same with service templates.
– OrangeDog
Jan 11 '19 at 18:28
my@x.service
enabled and my@y.service
disabled. All you will see from systemctl list-unit-files
is my@.service indirect
which is useless.
– Walf
Jul 23 '20 at 08:30
--all
with instances after I had made them them enabled to list status of all instances or start them all. Did use wildcards ? (systemctl list-unit-files 'my@*' --all
)
– digital_infinity
Sep 16 '20 at 07:33
--all
works correctly with status
but does not work with list-unit-files
– digital_infinity
Sep 16 '20 at 07:45
long_running_backup.service
or gpu_enabled_calculation.service
will lead to bugs in the future. – Unix philosophy at its best.
– ominug
Nov 18 '22 at 08:58
--no-legend
to systemctl and -w
to grep.
– ominug
Nov 18 '22 at 09:13
man systemctl
states:
--state=
The argument should be a comma-separated list of unit
LOAD
,SUB
, orACTIVE
states. When listing units, show only those in the specified states. Use--state=failed
to show only failed units.
Explanation:
LOAD
: Reflects whether the unit definition was properly loaded.
ACTIVE
: The high-level unit activation state, i.e. generalization of SUB
.
SUB
: The low-level unit activation state, values depend on unit type.
Though you can also use this to only show enabled
units with:
systemctl list-unit-files --state=enabled
If a unit is enabled
that means that the system will start it on startup. Though setting something to enabled
doesn't actually also start
it so you will need to do that manually, or reboot the system after setting it to enabled
.
--state=enabled
has no effect on systemd version 215 (on Raspbian 8 Jessie), but it does work on systemd version 229 (on Ubuntu 16.04.03 Xenial).
– mpb
Dec 17 '17 at 22:15
--state=generated
for generated unit files that might be running (the pihole-FTL service works this way, for example).
– mgalgs
Aug 26 '21 at 17:24
--type service
to filter only that type of units. 2. @mgalgs list-unit-files
now includes generated unitsservicename@.service
while --list-units
does
– Mat M
Mar 15 '23 at 12:51
To list all the systemd
service which are in state=active
and sub=running
systemctl list-units --type=service --state=running
To list all the systemd
serice which are in state=active
and sub either running or exited
systemctl list-units --type=service --state=active
--list-units
show the service(s) if they are based on a template servicename@.service
+1
– Mat M
Mar 15 '23 at 12:52
To see 'enabled' services including these that are still under upstart/init run:
systemctl list-unit-files --type service --state enabled,generated
To see all of the currently running services run:
systemctl list-units --type service --state running
sshd
vs. ssh
and syslog
vs. rsyslog
.
– OrangeDog
Jan 11 '19 at 18:35
There is a good GUI application called Stacer where you can manage all the services.
Check its Github link Stacer Github
Also check Web for more info
sudo apt-get install stacer
– SharpC
Jan 10 '24 at 16:29
Also overview of all active and failed services:
systemctl list-units --type service --state running,failed
In addition to the current answers, I use the following to get just the names of the services:
systemctl list-units --type=service --state=active,running | awk '/.*\.service/ {print $1}'
Rather than the tabular format, this makes it easier to pipe just those services to another program
To list also templated units, you might want to use:
systemctl list-units --all|grep yourservice
The --all
switch shows also all units which have been instantiated with
systemctl <service_name>@<argument>.service
From the man page:
When listing units with list-units, also show inactive units and units which are following other units. When showing unit/job/manager properties, show all properties regardless whether they are set or not.
Example:
systemctl openvpn@my_office_endopoint.service
Further reading: https://fedoramagazine.org/systemd-template-unit-files/
This for me has been the fastest way to check my running or failed services that are supposed to be enabled. With this, I know I do not have to run:
sudo shutdown -r now
I just use most of the above with comma separation on state:
systemctl list-units --type=service --state=running,enabled,failed,generated
To list user otheruser
's active user services:
sudo runuser -l otheruser-c "systemctl --user list-units --type=service --state=active"
man systemctl
. – Jos Jul 05 '16 at 18:35