Ubuntu assigns names to NICs using Predictable Network Interface Names. Ethernet interfaces are prefixed with en, wireless with wl, virtual with vir, and so on. This consistent naming scheme makes it easy to identify the interfaces. There are numerous ways to view and configure such network interfaces on Ubuntu.
List Adapters with lshw
lshw is used to get detailed info on a system’s hardware configuration. You can use it to list the installed physical network adapters by specifying the network class.
sudo lshw -class network
If you have multiple adapters installed, this is the best way to identify which interface corresponds to which device. Or if you don’t need the details and only want to shortlist them, you can use
sudo lshw -c network -short
List Connections with nmcli
Ubuntu uses the NetworkManager backend by default. You can use nmcli to query the state of NetworkManager and extract info relating to the network interfaces (both physical and logical).
Without any options, nmcli
lists all the interfaces, where they’re connected to, and various network parameters (IP Address, MAC Address, etc.).
nmcli
nmcli connection show
provides an overview of the active connection profiles only. nmcli device status
does the same as well.
nmcli c show
nmcli d status
On the other hand, nmcli device show
provides more detailed info on all known devices.
nmcli d show
Use ip to List Interfaces
The ip link
command is used to configure the state of network devices. Since we’re only trying to list the interfaces, we can use ip link show
. This can be shortened to ip link
or ip l
.
ip l
The ip address
command is used to view and configure the IP address assigned to network interfaces. In doing so, it lists the interfaces as well. Like earlier, we can shorten ip address show
to ip addr
or ip a
.
ip a
Use net-tools (Deprecated)
Various utilities from the net-tools package can list network interfaces. The other methods from this list are preferred as net-tools is actually deprecated, but these commands still work for now.
You can use ifconfig without any flags as its default behavior is to display network interfaces.
ifconfig
With netstat, you have to use the interfaces option.
netstat -i
Other Ways to List Network Interfaces
The /proc
and /sys
directories provide an interface to read system and device stats. Although a bit unorthodox, you can directly read the net and dev files from these directories to view the list of network interfaces.
ls /sys/class/net/
cat /proc/net/dev
Or, if you have some hardware or networking utilities like hwinfo
or iwconfig
installed, you can use those to list network interfaces as well.
sudo hwinfo --short --network
iwconfig