Linux: How to View Network Interfaces Quickly
In this article
Yes, you can list every network interface on a Linux machine with a handful of commands. The quickest way is to use the built‑in ip command, but tools like ifconfig, nmcli, and ls /sys/class/net also give useful details. Below is a step‑by‑step guide that covers the most common methods, common pitfalls, and troubleshooting tips.
What You'll Need
- A Linux system with a terminal (SSH or local console).
- Root or sudo privileges for commands that require elevated rights (e.g.,
ip link). - Basic familiarity with typing commands and reading command output.
Step-by-Step
- Open a terminal window. If you are working remotely, use SSH:
ssh user@hostname. If you are on the local machine, press Ctrl+Alt+T to launch one. - Check if the
iputility is available. Most modern distributions include it by default. Run:ip -V. The output will look likeip utility, iproute2-5.10.0. If the command is missing, install theiproute2package with your distribution’s package manager (e.g.,sudo apt install iproute2on Debian/Ubuntu). - List all network interfaces with their state and MAC addresses:
ip link show. The output groups each interface with an index number, name, and status. For example:1: lo: state UNKNOWN mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: state UP mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff - For a concise list that omits the detailed link properties, use:
ip -o link show | awk '{print $2,$4,$8}'. This prints the interface name, state, and MAC address in a single line per interface. - If you prefer the older
ifconfigstyle, run:ifconfig -a. This command displays all interfaces, whether active or not. Note thatifconfigis deprecated on many systems, but it is still available in thenet-toolspackage. - To see interfaces managed by NetworkManager, use:
nmcli device status. The output shows the device name, type, state, and connection name. This is useful on desktop distributions that rely on NetworkManager for Wi‑Fi and VPN handling. - For a quick glance at the kernel’s view of the network stack, list the directory:
ls /sys/class/net. Each entry corresponds to an interface name. This method does not show state or MAC addresses but is handy for scripting. - Optional: To filter interfaces by type, combine
ipwithgrep. For example, to show only Ethernet interfaces:ip -o link show | grep -E 'eth|enp'. - Optional: To display IP addresses assigned to each interface, run:
ip -o addr show. The output lists the interface name, address family, and IP address with netmask. - Optional: For wireless interfaces, use
iw devto list wireless devices and their status. This command is part of theiwpackage.
Common Mistakes
- Assuming
ifconfigis always present. Many modern distributions have removed it by default; installingnet-toolsis required. - Running
ip link showwithoutsudoand missing interfaces that require elevated privileges. Usesudo ip link showif you see incomplete output. - Misinterpreting the
statefield.UNKNOWNoften means the interface is not configured;DOWNindicates it is administratively disabled. - Confusing
lo(loopback) with a physical NIC. The loopback interface always exists and is used for local communication. - Using
nmcli device statuson a system that does not run NetworkManager. The command will return an error; useip link showinstead.
Tips
- Alias common commands in your shell for speed. For example, add
alias ipi='ip -o link show'to~/.bashrc. - Use
watch -n 1 ip -o link showto monitor interface changes in real time. - Combine
ipwithgrepandawkto extract specific fields for scripts. - For a GUI view on GNOME, open the Settings app and navigate to Network. The list there mirrors
nmcli device status. - When troubleshooting, check
/var/log/syslogor/var/log/messagesfor kernel messages about network devices.
Troubleshooting
If an interface does not appear in any list, try the following:
- Confirm the hardware is connected and powered on. For USB adapters, check
dmesg | grep -i usbto see if the kernel detected it. - Reload the kernel module that manages the interface. For example, for Intel Ethernet:
sudo modprobe -r e1000 && sudo modprobe e1000. - Verify that the interface is not blocked by a network manager or firewall. Run
rfkill listfor wireless devices. - Check the system’s BIOS/UEFI settings for options that disable onboard NICs.
- If the interface appears but shows
state UNKNOWN, ensure that the driver is loaded correctly. Look for errors indmesg | grep -i eth. - Restart the networking service:
sudo systemctl restart NetworkManagerfor NetworkManager orsudo systemctl restart networkingfor the traditional init system. - As a last resort, reboot the machine. Some kernel drivers require a full restart to initialize correctly.
Frequently Asked Questions
What is the difference between ip link show and ifconfig -a?
ip link show is part of the modern iproute2 suite and provides a detailed, structured view of interfaces, including state and MAC address. ifconfig -a is older, shows IP addresses and flags, but is deprecated on many systems.
How can I see only active interfaces?
Use ip link show up or nmcli device status | grep -i connected to filter for interfaces that are administratively up.
Why does my wireless interface show as UNKNOWN?
This usually indicates that the wireless driver has not yet initialized or that the interface is not associated with a network. Check dmesg for driver errors and ensure the Wi‑Fi card is powered on.
Can I use ip to change an interface’s MAC address?
Yes. Use sudo ip link set dev eth0 address 00:11:22:33:44:55. Remember that the change is temporary and will revert after a reboot unless scripted.
Is it safe to run ip link set dev commands without root?
No. Modifying interface settings requires root privileges; running the command without sudo will fail or produce insufficient permissions errors.