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

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

List of devices using Linux screenshot

 Lifewire

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 you can use the grep command to reduce the output as follows:

mount | grep /dev/sd

The results this time will 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 is displayed 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 much easier to read. You can see that we have one drive called sda, which offers 50 G of storage. It splits into just one partition, called sda1.

The drives fd0 (floppy) and sr0 (CD-ROM) reveal in this listing. The particular machine this listing drew from, called mint-vm, is a Linux Mint virtual machine running within 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

One thing that it is really worth learning about Linux is that if you want to list anything, then there is usually a command which starts with the letters ls.

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

lspci

The output from the above command is again very verbose, meaning you probably get more information than you bargained for.

Here is a short snapshot from our listing:

lspci listing screen

The listing lists everything from VGA controllers to USB, sound, Bluetooth, wireless, and Ethernet controllers.

The standard lspci listing is considered basic and if you want more detailed information about each device, you can 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 actually more readable and you can clearly see that we have a Qualcomm Atheros wireless card.

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

lspci -vv

If that isn't enough, try the following:

lspci -vvv

And if that isn't enough... No, we're only kidding. It stops there.

lspci -vvv output screen

The most useful aspect of lspci, other than listing devices, is the kernel driver that is used for that device. If the device isn't working, it is possibly 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, you will see the device appear on the list.

Summary

To summarize then, the best way to list anything out in Linux is to remember the following ls commands:

  • ls: List files in the file system
  • lsblk: List the block devices (i.e. drives)
  • lspci: List the pci devices
  • lsusb: List the USB devices
  • lsdev: List all the devices