How to Check Faults in Hardware Using Command Line

How-to-Guides from Kryotech

JB Benjamin
How-To-Guides from Kryotech
4 min readDec 23, 2020

--

What Do I Need?

What Can Go Wrong with Hardware?

Linux web servers are used for mission-critical business and consumer applications in many different types of infrastructures, including physical machines, virtualization, private, public, and hybrid cloud. Linux hardware infrastructure, including software-defined functionalities, relates to networking, storage, containers and multiple tools on Linux servers.

It takes some time to troubleshoot and solve hardware related issues on Linux. Even experienced sysadmins can spend hours working to solve mysterious software discrepancies.

Quick-Diagnosing Devices, Modules, and Drivers

The first step in troubleshooting usually is to display a list of the hardware installed on your Linux server. You can obtain detailed information on the hardware using the ls commands, for example: lspci, lsblk, lscpu, and lsscsi. Run the lsblk command:

lsblk

If the ls commands don’t reveal any errors, use init processes, for example, systemd, to see how the web server is working. systemd is the most popular init process for bootstrapping user spaces and controlling multiple system processes. Run the systemctl command:

systemctl status

Press ‘q’ to quit at the end. You can save the output as a file by pressing ‘s’ and then providing a name and pressing ‘enter’.

Exploring Further using Multiple Loggings

Dsmeg allows you to figure out errors and warnings in the kernel’s latest messages. Run the dmesg | more command:

dmesg | more

I would recommend also looking at your system logs, which can normally be found in the /var/log/messages files, which is where you’ll find errors related to specific issues. It’s worthwhile monitoring messages via the tail command in real-time when you modify your hardware, such as mounting an extra disk or adding an ethernet network interface.

tail -f /var/log/messages

Analyzing Network Functions

There may be hundreds of thousands of cloud-native applications to business services in a complex networking environment; this can include virtualization, multiple cloud, and hybrid cloud. This means you should analyze whether networking connectivity is working correctly as part of your troubleshooting. Useful commands to work out networking functions in the Linux server include, ip addr, traceroute, nslookup, dig, and ping, among others.

ip addr show

Next Steps

There are a lot of different types of hardware problems that you’ll experience and they can usually be diagnosed as falling into one or more of the following categories:

  • Non-functioning hardware

A dead piece of electronic equipment is usually the simplest case. If your power supply is gone, the machine just won’t turn on. A no-brainer.

  • Erratic hardware malfunctions

Probably the most difficult, most elusive type of problem. If you have a hardware component that’s throwing errors only once in a while, you may end up having sufficient data to correlate between these separate events and draw the right conclusion.

  • Firmware/driver problems

Driver problems will usually appear similar to hardware malfunctions, although you may get a more consistent experience. In many cases, you’ll have bad drivers that won’t communicate with the hardware at all, in others you’ll be running a buggy driver that causes your machine to misbehave in an unpredictable fashion.

  • Other considerations

It’s necessary to realize that some systems will have locked-down bios preventing you from making full use of hardware components or features, while others may have these components disabled on purpose.

If you’re experiencing issues with missing files or sporadic crashes and mysterious reboots you should try checking your hard disk drives:

smartctl -a /dev/sda

Conclusion

Troubleshooting Linux hardware requires considerable knowledge, including the use of powerful command-line tools and system logging. You should know how to diagnose the kernel space, which is where you can find the root cause of many of these hardware problems. Keep in mind that hardware issues in Linux come from many different sources, including devices, drivers, bios, networking, and even plain old hardware malfunctions.

--

--