1. Overview

It’s usually helpful to know the details of a system’s hardware. This can be beneficial for many reasons. For example, knowing our devices, we’re able to select the proper driver or module for a hardware component.

In this tutorial, we’ll see how to list all physically installed network cards in Linux.

2. Using the lshw Command

lshw is a handy command-line tool that creates comprehensive summaries of the system’s hardware components. To do this, it mainly examines several files in the /proc directory.

Let’s use lshw to list network cards on our system:

$ sudo lshw -C network
*-network 
description: Ethernet interface
product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
vendor: Realtek Semiconductor Co., Ltd.
physical id: 0
bus info: pci@0000:02:00.0
...

The -C network option filters the output to show only the network cards along with their properties. This information includes the description, vendor, driver, capabilities, and others.

Also, we can use the -short option to see an overview and ensure that only network cards are shown:

$ sudo lshw -C network -short
H/W path Device Class Description
==========================================================
/0/100/1c.4/0 eno1 network RTL8111/8168/8411 PCI Express Gig
/0/100/1c.5/0 wlo1 network RTL8723DE 802.11b/g/n PCIe Adapte
/b enx16b2b0d61b2c network Ethernet interface

Consequently, we can use this command to get valuable network information. Notably, lshw can also detect USB modem devices.

3. Using the lspci Command

The lspci command identifies the devices present in a system. Basically, it lists all devices connected to the PCI bus.

Let’s run it to see what network information we get:

$ sudo lspci -nnvmm | egrep -A 6 -B 1 -i 'network|ethernet'
Slot: 02:00.0
Class: Ethernet controller [0200]
Vendor: Realtek Semiconductor Co., Ltd. [10ec]
Device: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [8168]
SVendor: Hewlett-Packard Company [103c]
SDevice: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [84a7]
Rev: 15
Slot: 03:00.0
Class: Network controller [0280]
Vendor: Realtek Semiconductor Co., Ltd. [10ec]
Device: RTL8723DE 802.11b/g/n PCIe Adapter [d723]
SVendor: Hewlett-Packard Company [103c]
SDevice: RTL8723DE 802.11b/g/n PCIe Adapter [8319]

The -nn option displays the PCI vendor and device IDs in both numeric and textual forms. Similarly, -v produces verbose output. The -mm option renders the data in a machine-readable format for use inside scripts. Finally, the egrep command filters the output to show only network devices.

The output shows different records. Let’s examine the table structure with the data from the first device:

  • Slot (02:00.0): name of the slot where the device resides
  • Class (Ethernet controller): name of the class
  • Vendor (Realtek Semiconductor Co., Ltd.): name of the vendor
  • Device (RTL8111/8168/8411…): name of the device
  • SVendor (Hewlett-Packard Company): name of the subsystem vendor
  • SDevice (RTL8111/8168/8411…): name of the subsystem
  • Rev (15): revision number

Evidently, lspci can detect a USB device but can’t tell if it’s a networking device.

4. Using the inxi Command

inxi is a general-purpose utility for getting system information. Basically, we can use it to get an overview of network devices present on a system:

$ sudo inxi -N
Network:
Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
driver: r8169
Device-2: Realtek RTL8723DE 802.11b/g/n PCIe Adapter driver: rtw_8723de

The -N option of inxi outputs information about the system’s network devices. In this case, it shows two network devices and their corresponding drivers. First, it shows an Ethernet device. Secondly, it shows a wireless device, as indicated by the 802.11 protocol standard.

Furthermore, inxi can’t detect a USB as a modem device.

5. Using the /sys/class/net/ Directory

Let’s now see how the directory /sys/class/net/ lists network cards on our system.

Basically, if we run the ls command against this directory, we should see all available network interfaces. This includes both physical and virtual devices:

$ ls /sys/class/net/
eno1 enx16b2b0d61b2c lo vboxnet0 vboxnet1 wlo1

By using some filtering operations, we can show only the physical network cards:

$ find /sys/class/net -type l -not -lname '*virtual*' -printf '%f\n'
enx16b2b0d61b2c
eno1
wlo1

Let’s break down the above find command:

  • -type l: looks for symbolic links
  • -not -lname: ignores the path that contains the virtual string
  • -printf ‘%f\n’: prints only the basename of the path

Here, we see three network devices available on the system: eno1, enx16b2b0d61b2c, and wlo1. Additionally, the first two are wired network devices, whereas wlo1 is a wireless network device. Moreover, enx16b2b0d61b2c is a USB modem device.

Furthermore, we can use the name of the interface to get more information about it. For this, we navigate to the /sys/class/net/ directory. Now, we go to the relevant device directory by name. Finally, we open the uevent file, which contains information about the interfaces, such as their MAC address, driver, and others.

For example, to get data about the eno1 interface, we can use a simple cat command:

$ cat /sys/class/net/eno1/uevent
INTERFACE=eno1
IFINDEX=2

Additionally, this part of the /sys pseudo-filesystem can detect a USB modem connection.

6. Using the hwinfo Command

Like the lshw command, the hwinfo command shows the system’s hardware information.

Let’s use hwinfo to list network cards and their data:

$ sudo hwinfo --netcard
07: PCI 300.0: 0282 WLAN controller 
[Created at pci.386]
Unique ID: S6TQ.ssFGCi855d4
Parent ID: HnsE.sKZWCW5CsO8
SysFS ID: /devices/pci0000:00/0000:00:1c.5/0000:03:00.0
SysFS BusID: 0000:03:00.0
Hardware Class: network
Device Name: "WLAN"
...

The –netcard option along with the –short option display an overview of the system’s network devices. For example, the output shows the network card’s vendor, model, driver, and other details:

$ sudo hwinfo --netcard --short
network:                                                        
  wlo1                 Realtek RTL8723DE 802.11b/g/n PCIe Adapter
  eno1                 Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
  enx16b2b0d61b2c      Xiaomi Mi/Redmi series (RNDIS

To get a more detailed summary, we can omit –short. Additionally, hwinfo can also detect USB modem devices.

7. Using the HardInfo Utility

Finally, let’s discuss the HardInfo tool. Basically, it’s a GUI-based tool that shows system information while also providing a set of benchmarking tests.

To view the network card information, we can follow some simple steps:

  1. Open the HardInfo utility (hardinfo in the terminal)
  2. Go to the left-hand pane
  3. Expand the Devices category
  4. Click on PCI Devices
  5. In the right pane, scroll to the bottom
Network Cards

Here, we can see detailed information about all of the network devices on our system. For example, the Ethernet controller specifies the wired connection. Similarly, the Network controller shows a wireless connection as indicated by the 802.11b protocol.

Furthermore, it can’t judge a USB as a modem device.

8. Conclusion

To summarize, in this article, we’ve seen different ways of listing physical network cards:

  • with lshw and its -C option
  • using lspci
  • via inxi and the -N flag
  • from within /sys/class/net/
  • using hwinfo
  • by checking HardInfo

Overall, we can use this information to diagnose network issues or configure network settings.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.