How to list all physically installed Network Cards (Debian)?

Solution 1:

You can use lshw to see all devices on a machine. To view just the network devices enter:

lshw -class network

Solution 2:

ip link show will list everything that looks like a network interface.


Solution 3:

find /sys/class/net -type l -not -lname '*virtual*' -printf '%f\n'

Shows just interfaces that relate to a physical NIC.

Tried to find a type option to ip link show that would display non-logical, but alas:

ip link help 2>&1 | grep -A10 'TYPE :='
TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | macvtap |
          bridge | bond | ipoib | ip6tnl | ipip | sit | vxlan |
          gre | gretap | ip6gre | ip6gretap | vti | nlmon |
          bond_slave | ipvlan | geneve | bridge_slave | vrf }

It seems to be the one thing that ip link show cannot do. At least not without resorting to a script that first lists each of the above and then does grep -v against a final run without type specified.


Solution 4:

For Ethernet:

ls -d /sys/class/net/eth* | wc -l

Solution 5:

/proc/net/dev file has details on all interfaces. e.g.

$ cat /proc/net/dev
Inter-|   Receive                                                |  Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
    lo:    3562      60    0    0    0     0          0         0     3562      60    0    0    0     0       0          0
 wlan0: 2491781197 2034240    0    0    0     0          0         0 261797069 1502752    0    0    0     0       0          0
  eth0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0

As you can see, many columns and details are not very easy to read when you cat the file so I would suggest to use ifconfig command which reads that file and formats output nicely.

To list all interfaces use

/sbin/ifconfig -a

that will show you the unconfigured/down network interfaces as well as configured and active ones, as read from /proc/net/dev