Linux Show Network Devices Step-by-Step Guide
In this article
Displaying network devices in Linux helps identify and troubleshoot hardware and connections. This guide explains how to list them using command-line tools. First, ensure you have terminal access and optionally, administrative privileges for some commands.
What You'll Need
- Linux system with a terminal
- Basic command-line familiarity
- Optional: sudo access for full device details
Step-by-Step
- Open the terminal: Press Ctrl + Alt + T or click the terminal icon. This is the gateway to all command-line tools.
- Use the
ipcommand: Typeip link showand press Enter. This lists all network interfaces. Look for lines like1: lo(loopback) and2: eth0(Ethernet). Each line starts with a number, followed by a colon, the device name, and then its status. You can also useip a showorip addr showto see assigned IP addresses and interface details. - Use the
lscommand: Typels /sys/class/netto list network devices in the system's file structure. This directory represents network interfaces as they are recognized by the kernel. The command will return a list of device names likeeth0,wlan0, andlo. You can also usels /dev/net/tunto check for tun devices used in virtual private networks. - Use
nmclifor NetworkManager: If NetworkManager is installed, typenmcli deviceto see device status and type. This tool is particularly useful in desktop environments where GUI tools manage connections. The output will show the device name, type (e.g., Ethernet or Wi-Fi), and its current state (connected, disconnected, etc.). You can also usenmcli device statusto see the state of each network device. - Use
ifconfig(if available): Some systems still haveifconfig. Typeifconfigto see details of active interfaces. Note:ifconfigis deprecated in favor ofip. Whileifconfigstill works on many systems, it is no longer maintained and lacks support for newer technologies like VLANs and bridges. - View hardware details with
lspci: Typelspci | grep -i networkto see network hardware like Ethernet or wireless controllers. This command lists all PCI devices and filters the output for network-related devices. You can also uselspci -vto see detailed information about each device, including vendor and product IDs. This is especially useful when trying to identify the type of network card installed. - Check wireless devices with
iwconfig: Typeiwconfigto see wireless interface details. Note:iwconfigis deprecated; useiwornmcliinstead. For more detailed wireless information, useiw devto see device configurations andiw listto see supported features like channel widths and frequencies.
Common Mistakes
Users commonly confuse device names (like eth0 or ens33), and may not know which command to use. ifconfig is outdated and may not show all interfaces. Also, not running commands with sudo can prevent viewing full details. For example, ip link show may not display detailed hardware information without elevated privileges.
Tips
Use ip a (short for ip addr show) to see IP addresses and interface status. For detailed hardware specs, use lshw -class network if installed. Combine ip link with grep for easier filtering, like ip link show | grep 'eth'. You can also use ethtool to get detailed information about a specific device, such as speed, duplex, and driver version. For example, ethtool eth0 will show the current settings of the eth0 interface.
Troubleshooting
If no devices appear, ensure the terminal is open and commands are typed correctly. For missing tools like ip or nmcli, install iproute2 or NetworkManager via your package manager. If wireless is missing, check if the hardware is enabled in BIOS or if drivers are installed. Restarting the network manager with systemctl restart NetworkManager may help. For systems using systemd-networkd, run systemctl restart systemd-networkd to refresh network configurations.
Real-World Examples
Suppose you're trying to diagnose a network issue and need to know which interfaces are active. Running ip link show gives you a list of interfaces and their states (UP/DOWN). If you see 2: eth0: , it means eth0 is up and functioning. If it's DOWN, use ip link set eth0 up to bring it online. If you're working with wireless interfaces and need to see signal strength, use iw dev wlan0 station get to see details like signal quality and noise level.
Additional Tools
For more advanced diagnostics, use arp -a to see connected devices on the local network or tcpdump to capture and analyze network traffic. tcpdump -i eth0 will start capturing packets on eth0. You can also use dhclient eth0 to manually request an IP address from a DHCP server, which is useful when diagnosing IP assignment issues.