To list all devices in Linux, use the lsblk, lspci, lsusb, and lshw commands depending on the type of hardware you need to identify. These tools query the kernel and the system bus to report connected peripherals, internal controllers, and storage volumes.

General Hardware Inventory

The lshw (list hardware) command provides a comprehensive report of the entire system configuration. It detects CPU, memory, disks, network adapters, and bus controllers in a single output.

Run sudo lshw to see a detailed list. Because this command accesses low-level system information, it requires root privileges to display all hardware details; running it without sudo will result in many "unknown" or "unclaimed" entries.

If the output is too long to read, use sudo lshw -short. This creates a compact table that lists the hardware path, the device class, and the specific model name. This is the fastest way to verify if a piece of hardware is physically recognized by the operating system before checking for driver issues.

You can also export this data to a file for analysis. Using sudo lshw -html > hardware.html generates a web page that organizes the device tree into a readable format. This is useful when you need to share your hardware specifications with a technician or a support forum.

PCI and USB Peripherals

The lspci command lists all devices connected to the PCI (Peripheral Component Interconnect) bus. This includes your graphics card, network cards, NVMe drives, and onboard audio controllers.

Run lspci for a basic list. To see more detail, such as the kernel driver currently in use for a specific device, use lspci -k. This is critical for determining if a device is detected but lacks a working driver, as it will explicitly show the "Kernel driver in use" or "Kernel modules" available for that hardware.

For external devices, use lsusb. This command lists all USB controllers and the devices attached to them, such as mice, keyboards, external hard drives, and webcams.

The basic lsusb output shows the Bus and Device ID along with the manufacturer and product name. For deep technical details, such as power requirements, USB version (2.0 vs 3.0), and endpoint descriptors, use lsusb -v. Note that the verbose output is extremely long, so it is best to pipe it into a pager, such as lsusb -v | less.

Storage and Block Devices

A common misconception is that ls on the /dev directory is the best way to list disks. While ls /dev/sd* shows the device files, it does not tell you the size, partition layout, or mount point of the drives.

The correct tool for storage is lsblk (list block devices). It displays a tree-like structure showing every disk and its associated partitions. It lists the name, size, type (disk or part), and where the device is mounted in the file system.

Use lsblk -f to see the file system type (such as ext4, xfs, or ntfs) and the UUID (Universally Unique Identifier) for each partition. The UUID is the most reliable way to identify a disk in the /etc/fstab file because device names like /dev/sdb can change between reboots if you add or remove drives.

For low-level partition tables and sector information, use sudo fdisk -l. This command lists the disk size in bytes, the disk identifier, and the start and end sectors of every partition. It is the primary tool for verifying if a disk is initialized with a GPT or MBR partition table.

Network Interface Detection

To list network devices, use the ip link show command. This displays all available network interfaces, including physical Ethernet ports, Wi-Fi cards, and virtual loopback interfaces.

Look for the interface name, such as eth0, enp3s0, or wlan0. The state of the device is indicated by the word UP or DOWN. If a device is DOWN, it means the hardware is detected but the interface is not currently active or connected to a network.

If you need to see the MAC address (Hardware Address), it is listed next to the link/ether label in the output. This unique identifier is necessary for configuring DHCP reservations or MAC filtering on a router.

Another useful tool is nmcli device, which is part of the NetworkManager suite. It provides a cleaner, human-readable summary of the device, the type of connection (wifi, ethernet), and the current connection status.

Identifying Hardware by Signs

When searching for a device that isn't appearing in the lists above, check for these specific signs in the system logs to determine why the hardware is missing.

  • dmesg output: Run dmesg | grep -i usb or dmesg | grep -i pci immediately after plugging in a device. If the kernel sees the hardware, it will log the detection event here, even if no driver is available to make the device functional.
  • Unknown Device: In lspci, a device listed as "Unknown" usually means the hardware ID is not in the local PCI ID database. You can often resolve this by updating the database with sudo update-pciids.
  • Unclaimed: In lshw, an "unclaimed" device means the hardware was found, but the Linux kernel has no driver that matches that specific hardware ID.
  • Missing /dev node: If a device appears in lspci but not in lsblk or ip link, the hardware is physically present, but the kernel driver failed to initialize the device.

Rule of Thumb for Device Discovery

Follow a hierarchical approach to avoid getting overwhelmed by data. Start with the most general tool and narrow down to the specific bus.

First, use lsblk for storage or ip link for networking if you are looking for a specific functional device. If those fail, move to lspci or lsusb to see if the hardware is visible on the system bus. Finally, use sudo lshw for a full system audit or dmesg to troubleshoot a device that refuses to initialize.

Labels and naming conventions for devices (like sda versus nvme0n1) differ by kernel version and hardware interface. Always rely on the UUID or the hardware serial number provided by lsblk -f or udevadm info when writing scripts or configuration files to ensure you are targeting the correct physical device regardless of how the system names it during boot.