Display active but disabled systemd services.
Use the following script to display active but disabled services.
$ while read -r line; do unit=$(echo $line | awk '{print $1}') if [ "$(systemctl is-enabled $unit 2>/dev/null)" == "disabled" ]; then echo "Service $unit is active but disabled" fi done < <(systemctl list-units --no-pager --no-legend --state active --type service)
Sample usage.
$ while read -r line; do unit=$(echo $line | awk '{print $1}'); if [ "$(systemctl is-enabled $unit 2>/dev/null)" == "disabled" ]; then echo "Service $unit is active but disabled"; fi done < <(systemctl list-units --no-pager --no-legend --state active --type service)
Service acpid.service is active but disabled Service nfs-blkmap.service is active but disabled Service rtkit-daemon.service is active but disabled Service upower.service is active but disabled
Inspect specific service.
$ systemctl status rtkit-daemon.service
● rtkit-daemon.service - RealtimeKit Scheduling Policy Service Loaded: loaded (/lib/systemd/system/rtkit-daemon.service; disabled; vendor preset: enabled) Active: active (running) since Sun 2021-04-18 18:00:55 CEST; 1 weeks 2 days ago Main PID: 1381 (rtkit-daemon) Tasks: 3 (limit: 18952) Memory: 1.2M CGroup: /system.slice/rtkit-daemon.service └─1381 /usr/libexec/rtkit-daemon kwi 27 08:55:31 desktop rtkit-daemon[1381]: Supervising 10 threads of 8 processes of 1 users. kwi 27 10:18:20 desktop rtkit-daemon[1381]: Supervising 9 threads of 8 processes of 1 users. kwi 27 10:18:20 desktop rtkit-daemon[1381]: Successfully made thread 185112 of process 1881 owned by '1000' RT at priority 5. kwi 27 10:18:20 desktop rtkit-daemon[1381]: Supervising 10 threads of 8 processes of 1 users. kwi 27 20:14:26 desktop rtkit-daemon[1381]: Supervising 9 threads of 8 processes of 1 users. kwi 27 20:14:26 desktop rtkit-daemon[1381]: Successfully made thread 190193 of process 1881 owned by '1000' RT at priority 5. kwi 27 20:14:26 desktop rtkit-daemon[1381]: Supervising 10 threads of 8 processes of 1 users. kwi 27 22:35:13 desktop rtkit-daemon[1381]: Supervising 9 threads of 8 processes of 1 users. kwi 27 22:35:13 desktop rtkit-daemon[1381]: Successfully made thread 215875 of process 1881 owned by '1000' RT at priority 5. kwi 27 22:35:13 desktop rtkit-daemon[1381]: Supervising 10 threads of 8 processes of 1 users.
Simple as that.