Open In App

How to List Network Interfaces in Linux?

Last Updated : 01 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

In Linux, a Network Interface serves as the communication link between a computer and a network. It is a crucial component that enables the transmission and reception of data between the system and external networks, such as the Internet or local area networks. Each network interface is associated with a unique identifier, often referred to as the interface name (e.g., eth0 or wlan0), and is configured with specific settings like IP addresses, subnet masks, and gateway information. Linux supports a variety of network interface types, including Ethernet, Wi-Fi, and virtual interfaces, allowing users to establish and manage connections seamlessly. In this article, we will explore 10 different methods through which we can list all network interfaces in the Linux Operating System.

How to list network interfaces in Linux?

Below we have listed all the 10 methods through which we can list network interfaces on Linux OS:

We will see each of the methods with its implementation.

Using ip command to list network interfaces in Linux

In this method, you can use the “ip” command to list network interfaces in Linux. Open a terminal and type the following command:

ip addr

Using ip command

Using ip command

This command displays a list of network interfaces along with their corresponding details, such as the interface name, state, and hardware address. The “ip” command provides extensive network configuration and information capabilities in Linux.

Using nmcli to list network interfaces in Linux

In this method, you can utilize the “nmcli” (NetworkManager Command-Line Interface) tool to list network interfaces in Linux. Execute the following command in the terminal:

nmcli device status
Using nmcli

Using nmcli

This command provides an overview of network interfaces managed by NetworkManager, including details such as device type, state, connection status, and associated IP addresses.

Using netstat to list network interfaces in Linux

In this method, the “netstat” command with the “-i” option can be used to list network interfaces in Linux. Execute the following command in the terminal:

netstat -i

Using netstat

Using netstat

This command displays a table of network interfaces along with their respective transmission and reception statistics, such as bytes and packets.

Using ifconfig command to list network interfaces in Linux

In this method, you can use the “ifconfig” command to list network interfaces in Linux. Simply execute the following command in the terminal:

ifconfig

Using ifconfig command

Using ifconfig command

This command displays a detailed output that includes information about all active network interfaces, such as the interface name, hardware address, IP address, and other configuration details.

Printing /proc/net/dev file to list network interfaces in Linux

In this method, you can print the contents of the “/proc/net/dev” file to list network interfaces in Linux. Execute the following command in the terminal:

cat /proc/net/dev

Printing /proc/net/dev file

Printing /proc/net/dev file

This command displays a detailed table of network interfaces along with statistics like received and transmitted bytes and packets. The “/proc/net/dev” file is a virtual file that provides kernel-level information about network devices.

Listing /sys/class/net/ directory to list network interfaces in Linux

In this method, you can list network interfaces in Linux by examining the contents of the “/sys/class/net/” directory. Execute the following command in the terminal:

ls /sys/class/net/

Listing /sys/class/net/ directory

Listing /sys/class/net/ directory

This command provides a simple list of network interface names present in the “/sys/class/net/” directory. Each entry corresponds to a network interface, such as Ethernet or wireless devices.

Using hwinfo command to list network interfaces in Linux

In this method, the “hwinfo” command with the “–short” and “–network” options are used to list network interfaces in Linux. Execute the following command in the terminal:

sudo hwinfo --short --network

Using hwinfo command

Using hwinfo command

This command provides a summary of hardware information related to network devices. By using “hwinfo,” users can obtain detailed information about their network interfaces, including the interface names, driver details, and configuration.

Using lshw command to list network interfaces in Linux

In this method, the “lshw” command with the “-class network” and “-short” options are used to list network interfaces in Linux. Execute the following command in the terminal:

sudo lshw -class network -short

Using lshw command

Using lshw command

This command provides a summary of network-related hardware information, including network interface names, descriptions, and driver information. The use of “sudo” may be required to ensure sufficient privileges for accessing hardware information.

Using iwconfig to list network interfaces in Linux

In this method, the “iwconfig” command is used to list wireless network interfaces in Linux. Execute the following command in the terminal:

iwconfig

Using iwconfig

Using iwconfig

This command specifically focuses on wireless interfaces and provides information about their configuration, including details like the interface name, the ESSID (Extended Service Set Identifier), access point MAC address, signal strength, and more.

Using lspci command to list network interfaces in Linux

In this method, the “lspci” command with the pipe and “egrep” combination is used to list network-related devices in Linux. Execute the following command in the terminal:

lspci | egrep -i 'network|ethernet|wireless|wi-fi'

Using lspci command

Using lspci command

This command filters the output of “lspci” to display only the lines containing keywords such as ‘network,’ ‘ethernet,’ ‘wireless,’ or ‘wi-fi.’ The result is a concise list of PCI devices related to networking, making it easier to identify network interfaces and associated hardware on the system.

Conclusion

In conclusion, users can list network interfaces through various methods. Common commands like “ip link show,” “nmcli device show,” “ifconfig,” and “netstat -i” provide detailed information. Additionally, examining directories such as “/proc/net/dev” and “/sys/class/net/” offers direct insights. Tools like “lshw,” “iwconfig,” and “lspci” cater to specific needs, showcasing hardware details. Each method serves as a valuable resource for users to efficiently retrieve network interface information based on their preferences and requirements.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads