Saturday, November 17, 2012

Linux: How to identify installed hardware

Studying for the LPI Certification (Level 1), one of the first things you learn is how to identify hardware in a running Linux system.

From a high-level perspective, there are two basic views of the hardware: yours, and the computer's. It's good to keep in mind that these two views can and often are very different. In this case, when we say "the computer", we mean the kernel, because it is the kernel's job to interface between the software and the hardware, via device drivers. The kernel always maintains a clear picture of what hardware it thinks is installed.

What tools does the system administrator have to find out what hardware the kernel thinks is installed? There are several. Far and away the most user-friendly of these are kinfocenter in KDE and 'hardinfo' in Gnome. These tools, however, are available only if a desktop environment is installed, which on servers is usually not the case.

Without a desktop environment, you have to rely on the lower-level (i.e. command-line) tools. On openSUSE, for example, there is 'hwinfo' (see the intro for details). One particularly useful example:
# hwinfo --disk
17: IDE 00.0: 10600 Disk                                        
  [Created at block.245]
  Unique ID: 3OOL.1NQWI8jrVC4
[output truncated]

For a more detailed overview, see HowToIdentifyADevice on the Debian Wiki.

The following area is reserved for future notes on the various command-line tools:


These are virtual files in the /proc hierarchy, accessible using cat. They provide a low-level view of the hardware.

lsusb -t

lspci -t

Most Linux distributions these days have more-or-less a single kernel which is used for large swathes of users. The installation app probes the hardware and attempts to install all the drivers automatically. In such environments, the drivers take the form of kernel modules. Looking at what modules have been loaded into the kernel can be very useful when troubleshooting hardware issues:

modprobe -v
modprobe -r

No comments:

Post a Comment