Systemd systemctl list all failed units/services on Linux

Is there is a command to print list all failed units or services when using systemd on Linux? Can you tell me the systemctl command to list all failed services on Linux?

This quick tutorial explains how to find/list all failed systemd services/units on Linux operating systems using the systemctl command.

ADVERTISEMENTS

Systemd systemctl list all failed units/services command

The systemctl command used to control the systemd system and service management. To list units that systemd currently has in memory, pass the list-units argument to the systemctl as follows on Linux:
sudo systemctl list-units --failed
## OR ##
sudo systemctl list-units --state failed

Linux systemctl list all failed units or services command

The systemctl command options to list all failed units/services

A note about the is-failed option

We can check whether any of the specified units or services are in a “failed” state under Linux. The following command returns an exit code 0 if at least one has failed, non-zero otherwise. Unless the --quiet option passed to the systemctl command, this will also print the current unit state to standard output. So, if you know the service or unit name try the following command:
sudo systemctl is-failed {service-name-here}
sudo systemctl is-failed nginx.service
sudo systemctl is-failed vboxweb.service

Another option is to run the following simple command along with the grep command to list failed services with systemctl:
sudo systemctl list-units | grep -i failed

systemctl options to List all failed units on Ubuntu or Debian Linux

Click to enlarge

How to find status of systemd unit or service

Pass the status option as follows:
sudo systemctl status {service-name}
sudo systemctl status ssh.service
sudo systemctl status nginx.service
sudo systemctl status vboxweb.service

Find systemctl service status command

Click to enlarge

Show properties of a service unit

Run the following command:
sudo systemctl show {service-name}
sudo systemctl show vboxweb.service

How to view log messages

Log messages can provide in-depth information about services that we can use to debug issues. The syntax is as follows:

Display all messages

journalctl
journalctl | grep 'error'

Show only kernel messages

journalctl -k

View live messages on screen as they appear

journalctl -f

How to view service specific messages only

journalctl -u {service-name-here}
journalctl -u ssh.service
journalctl -u vboxweb.service

-- Reboot --
Apr 17 00:41:06 nixcraft-wks01 systemd[1]: Starting VirtualBox Web Service...
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]: WARNING: The character device /dev/vboxdrv does not exist.
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]:          Please install the virtualbox-dkms package and the appropriate
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]:          headers, most likely linux-headers-generic.
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]:          You will not be able to start VMs until this problem is fixed.
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]: Oracle VM VirtualBox web service Version 6.0.14_Ubuntu
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]: (C) 2007-2019 Oracle Corporation
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]: All rights reserved.
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]: 00:00:00.001759 main     VirtualBox web service 6.0.14_Ubuntu r132055 linux.amd64 (Oct 17 2019 07:24:16) release log
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]: 00:00:00.001764 main     Log opened 2020-04-16T19:11:06.826028000Z
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]: 00:00:00.001765 main     Build Type: release
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]: 00:00:00.001768 main     OS Product: Linux
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]: 00:00:00.001769 main     OS Release: 5.3.0-46-generic
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]: 00:00:00.001770 main     OS Version: #38-Ubuntu SMP Fri Mar 27 17:37:05 UTC 2020
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]: 00:00:00.001831 main     DMI Product Name: 20QVCTO1WW
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]: 00:00:00.001855 main     DMI Product Version: ThinkPad X1 Extreme 2nd
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]: 00:00:00.001920 main     Host RAM: 31866MB (31.1GB) total, 31409MB (30.6GB) available
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]: 00:00:00.001924 main     Executable: /usr/lib/virtualbox/vboxwebsrv
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]: 00:00:00.001924 main     Process ID: 1675
Apr 17 00:41:06 nixcraft-wks01 vboxwebsrv[1675]: 00:00:00.001925 main     Package type: LINUX_64BITS_GENERIC (OSE)
Apr 17 00:41:06 nixcraft-wks01 systemd[1]: Started VirtualBox Web Service.
Apr 20 11:44:00 nixcraft-wks01 systemd[1]: Stopping VirtualBox Web Service...
Apr 20 11:44:05 nixcraft-wks01 systemd[1]: vboxweb.service: Succeeded.
Apr 20 11:44:05 nixcraft-wks01 systemd[1]: Stopped VirtualBox Web Service.
Apr 20 11:44:05 nixcraft-wks01 systemd[1]: Starting VirtualBox Web Service...
Apr 20 11:44:05 nixcraft-wks01 systemd[1]: vboxweb.service: Can't open PID file /run/vboxweb.pid (yet?) after start: No such file or directory
Apr 20 11:44:05 nixcraft-wks01 systemd[1]: vboxweb.service: Failed with result 'protocol'.
Apr 20 11:44:05 nixcraft-wks01 systemd[1]: Failed to start VirtualBox Web Service.
-- Reboot --
Apr 20 11:52:48 nixcraft-wks01 systemd[1]: Starting VirtualBox Web Service...
Apr 20 11:52:48 nixcraft-wks01 systemd[1]: vboxweb.service: Can't open PID file /run/vboxweb.pid (yet?) after start: Operation not permitted
Apr 20 11:52:48 nixcraft-wks01 systemd[1]: vboxweb.service: Failed with result 'protocol'.
Apr 20 11:52:48 nixcraft-wks01 systemd[1]: Failed to start VirtualBox Web Service.
-- Reboot --
Apr 20 12:17:31 nixcraft-wks01 systemd[1]: Starting VirtualBox Web Service...
Apr 20 12:17:31 nixcraft-wks01 systemd[1]: vboxweb.service: Can't open PID file /run/vboxweb.pid (yet?) after start: Operation not permitted
Apr 20 12:17:31 nixcraft-wks01 systemd[1]: vboxweb.service: Failed with result 'protocol'.
Apr 20 12:17:31 nixcraft-wks01 systemd[1]: Failed to start VirtualBox Web Service.
-- Reboot --
Apr 20 12:35:06 nixcraft-wks01 systemd[1]: Starting VirtualBox Web Service...
Apr 20 12:35:06 nixcraft-wks01 systemd[1]: vboxweb.service: Can't open PID file /run/vboxweb.pid (yet?) after start: Operation not permitted
Apr 20 12:35:06 nixcraft-wks01 systemd[1]: vboxweb.service: Failed with result 'protocol'.
Apr 20 12:35:06 nixcraft-wks01 systemd[1]: Failed to start VirtualBox Web Service.
-- Reboot --
Apr 21 00:09:56 nixcraft-wks01 systemd[1]: Starting VirtualBox Web Service...
Apr 21 00:09:56 nixcraft-wks01 systemd[1]: vboxweb.service: Can't open PID file /run/vboxweb.pid (yet?) after start: Operation not permitted

We can now search for those errors online or read man pages to sort it out.

Conclusion

We learned how to show services/units that failed to run on Linux using the systemctl command. See systemctl man page here for more info.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.