List Network Interfaces in Ubuntu
Ethernet, Wireless or Bluetooth? Learn multiple ways of listing network interfaces in the Ubuntu command line.
The network interface is nothing but a software component, usually implemented in the kernel, and allows you to communicate using the network hardware. They could be Ethernet, Wireless, Bluetooth etc.
In this tutorial, I will walk you through multiple ways to list the network interfaces along with their details in Ubuntu.
1. Using the ip command
Being one of the most basic networking commands, the ip command is used to find the IP address and manage networks in Linux.
And to list the network interfaces using the ip command, all you have to do is execute the ip command with the link
and the show
option as shown:
ip link show
And as you can see, the ip command gave me the names of all six network interfaces, the MAC addresses, current status, and other information.
2. Using the nmcli command
The nmcli command in Linux is used to manage networks when your distro is utilizing the NetworkManager
service and most of the distros do ship with it.
So to list the network interface, all you have to do is execute the following command:
nmcli device status
Pretty clean output. Isn't it?
3. Using the netstat command
The netstat command is mainly used by system admins to monitor the network but it can also be used to list the network interfaces.
To use the netstat command to list the network interfaces, you'd have to use the following command:
netstat -i
And as you can see, apart from listing the network interfaces, it gives tonnes of additional information so here's a brief explanation of each column:
MTU
: shows the largest packet size that can be transmitted over the network.RX-OK
: indicates the number of packages received successfully by an interface.RX-ERR
: shows the number of packets received with an error.RX-DRP
: number of packets that were dropped while receiving because the buffer was full.RX-OVR
: number of packets that were dropped while receiving because the buffer was overflowed.TX-OK
: shows the number of packets transmitted successfully over the network.TX-ERR
: indicates the number of packets that were not transmitted successfully.TX-DRP
: number of packets that were dropped while transmission because of the buffer was full.RX-OVR
: number of packets that were dropped while transmission because of buffer overflow.Flg
: it shows the flag associated with the network.
4. Using the ifconfig command
The ifconfig command is one of the most popular CLI tools which is used to monitor, configure and troubleshoot the network in Linux.
And when executed without any options, the ifconfig command brings all the basic details of the network interfaces:
ifconfig
Got an error saying ifconfig command not found
? Here's an easy solution to get away from the error:
5. By listing the contents of /sys/class/net
The ls /sys/class/net
is a directory where you'd find the directory for each network interface.
This makes it the easiest method in the whole tutorial but the only downside is you don't get any additional information apart from the name of the interface.
Here, I will use the ls command to list the directories in the following manner:
ls /sys/class/net/
Bonus Tip: Know the brand of the interface
The above commands do not tell you if your wireless adapter is by Atheros or Broadcom or some other brand.
You can list the make of the network adapters by using the lshw command. This command is used for getting the hardware details of your Linux system.
To get the network interface details, use it like this:
lshw -C network
Just getting started? Know the basics first
If you are just getting started with networking, knowing the basic commands is the most crucial thing.
So for that purpose, we have compiled a list of the most basic networking commands including their examples:
I hope you will find this guide helpful. And if you have any queries, feel free to ask in the comments.
A software engineer who loves to tinker with hardware till it gets crashed. While reviving my crashed system, you can find me reading literature, manga, or watering my plants.