Bash-based hardware detection for PCI and USB

DISCOVERY SCRIPTS

If you need fast answers for what's inside, you can use a Bash script to obtain an inventory of hardware on your Linux system.

If you operate outside of the mainstream distributions or compile your own Linux system, whether an em-bedded Linux, a rescue system, or just a do-it-yourself distro, you need to solve the issue of finding the right kernel modules for your collection of hardware. Armed with some background know-ledge, you can use almost any programming language to create a system for PCI or USB hardware detection. In this article, I’ll show you a method for obtaining information about devices on your Linux system with a Bash script. Using sysfs or proc, you can find all the information you need about the manufacturer, device, and device class just by asking the kernel.

Debian hotplug is designed for little more than loading drivers and configuring devices. The collection of scripts discussed in this article helps Linux to respond when a network cable is plugged in or when a cellphone is in the vicinity. Read on for more on how to define custom hotplug events.