Systemd – Parsable Output from Systemctl (List All Units)

systemctlsystemd

I am not happy with the output of systemctl

I have a script which parses the output of

systemctl list-units -t service --full --all

The beginning of the output look like this:

  UNIT                                   LOAD      ACTIVE     SUB          JOB   DESCRIPTION                                                                  
  after-local.service                    loaded    inactive   dead               /etc/init.d/after.local Compatibility                                        
● amavis.service                         not-found inactive   dead               amavis.service                                                               
  apparmor.service                       loaded    active     exited             Load AppArmor profiles                                                       
  auditd.service                         loaded    active     running            Security Auditing Service                                   

On a different systemd the column with the dot (before amavis.service) does not exist.

Is there a machine/script readable output of systemctl?

Best Answer

I use this for machine-parsable output, adding --plain --no-legend, for example:

systemctl list-units -t service --full --all --plain --no-legend