How to Use Linux to Find the Names of the Devices on Your Computer

Variations of the 'ls' command show devices on your computer

Listing the devices, drives, PCI devices, and USB devices on your computer involves a series of commands easily invoked from a shell prompt in Linux.

Use the 'mount' Command

The most simple syntax you can use is as follows:

mount

The output from the above command is fairly verbose and will be something like this:

Linux mount display screen

Hard drives generally start with /dev/sda or /dev/sdb, so use the grep command to reduce the output as follows:

mount | grep /dev/sd

The results show something like this:

/dev/sda4 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
/dev/sda1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)

This doesn't list your drives but it does list your mounted partitions. It doesn't list partitions that aren't yet mounted.

The device /dev/sda usually stands for the first hard drive on your system, and if you have a second hard drive, then it will be mounted to /dev/sdb. If you have an SSD, then this will likely be mapped to /dev/sda and the hard drive mapped to /dev/sdb.

Use 'lsblk' to List Block Devices

Mount is fine for listing mounted devices, but it doesn't show every device you have, and the output is verbose, making it difficult to read.

The best way to list the drives in Linux is to use lsblk as follows:

lsblk

The information displays in a tree format with the following information:

  • Name
  • Major Minor version number
  • Is it removable
  • Size
  • Is it read-only
  • Is it a disk or a partition
  • Where is the partition mounted

The display looks something like this:

lsbkl listing screen

The information is easier to read. It displays one drive called sda, which offers 50 G of storage. It splits into one partition, called sda1.

The drives fd0 (floppy) and sr0 (CD-ROM) appear in this listing. The particular machine this listing drew from, called mint-vm, is a Linux Mint virtual machine running in the Hyper-V system on a Windows 10 computer. Hyper-V provisions a virtual floppy and CD-ROM drive by default.

How to List PCI Devices

To list the PCI devices use the lspci command as follows:

lspci

The output from the above command is verbose, meaning you probably get more information than you need.

Here's a short snapshot as an example:

lspci listing screen

The listing lists devices, including VGA controllers, USB controllers, sound, Bluetooth, wireless, and Ethernet controllers.

The standard lspci listing is considered basic, and if you want more detailed information about each device, run the following command:

lspci -v

The information for each device looks something like this:

02:00.0 Network controller: Qualcomm Atheros AR9485 Wireless Network Adapter (rev 01)
Subsystem: Dell AR9485 Wireless Network Adapter
Flags: bus master, fast devsel, latency 0, IRQ 17
Memory at c0500000 (64-bit, non-prefetchable) [size=512K]
Expansion ROM at c0580000 [disabled] [size=64K]
Capabilities:
Kernel driver in use: ath9k
Kernel modules: ath9k

The output from the lspci -v command is more readable.

You can get even more verbose output by using the following command:

lspci -vv

If that isn't enough information, try the following:

lspci -vvv
lspci -vvv output screen

The most useful aspect of lspci, other than listing devices, is the kernel driver used for that device. If the device isn't working, it is worth researching whether there is a better driver available for the device.

List the USB Devices Attached to the Computer

To list the USB devices available for your computer, use the following command:

lsusb

The output will be something like this:

Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 005: ID 0c45:64ad Microdia
Bus 001 Device 004: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 001 Device 007: ID 0cf3:e004 Atheros Communications, Inc.
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 0bc2:231a Seagate RSS LLC
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 002: ID 054c:05a8 Sony Corp.
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

If you insert a USB device into the computer, such as an external hard drive, and then run the lsusb command, the device appears on the list.

Summary

The best way to list anything in Linux is to remember the following ls commands:

  • ls: List files in the file system.
  • lsblk: List block devices (for example, the drives).
  • lspci: List PCI devices.
  • lsusb: List USB devices.
  • lsdev: List all devices.