HowTo: Linux Show List Of Network Cards

Posted on in Categories , last updated September 4, 2012

How do I display a list of all network cards under Linux operating systems?

You can use any one of the following command to list network cards installed under Linux operating systems. Please note that the ifconfig and ip commands will also display interfaces information about vpn, loopback, and other configured interfaces.

  1. lspci command : List all PCI devices.
  2. lshw command : List all hardware.
  3. dmidecode command : List all hardware data from BIOS.
  4. ifconfig command : Outdated network config utility.
  5. ip command : Recommended new network config utility.

lspci command

Type the following command:
# lspci | egrep -i --color 'network|ethernet'
Sample outputs:

09:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5761e Gigabit Ethernet PCIe (rev 10)
0c:00.0 Network controller: Intel Corporation Ultimate N WiFi Link 5300

lshw command

The lshw command can extract detailed information on the hardware configuration of the machine including network cards. Type the following command:
# lshw -class network
Sample outputs:

  *-network DISABLED      
       description: Wireless interface
       product: Ultimate N WiFi Link 5300
       vendor: Intel Corporation
       physical id: 0
       bus info: [email protected]:0c:00.0
       logical name: wlan0
       version: 00
       serial: 00:21:6a:ca:9b:10
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
       configuration: broadcast=yes driver=iwlwifi driverversion=3.2.0-0.bpo.1-amd64 firmware=8.83.5.1 build 33692 latency=0 link=no multicast=yes wireless=IEEE 802.11abgn
       resources: irq:46 memory:f1ffe000-f1ffffff
  *-network
       description: Ethernet interface
       product: NetXtreme BCM5761e Gigabit Ethernet PCIe
       vendor: Broadcom Corporation
       physical id: 0
       bus info: [email protected]:09:00.0
       logical name: eth0
       version: 10
       serial: b8:ac:6f:65:31:e5
       size: 1GB/s
       capacity: 1GB/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm vpd msi pciexpress bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=tg3 driverversion=3.121 duplex=full firmware=5761e-v3.71 ip=192.168.1.5 latency=0 link=yes multicast=yes port=twisted pair speed=1GB/s
       resources: irq:48 memory:f1be0000-f1beffff memory:f1bf0000-f1bfffff

ifconfig and ip command

To see all configured network devices, enter:
# ifconfig -a
OR
# ip link show
OR
# ip a
Sample outputs:

1: lo:  mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc mq state UP qlen 1000
    link/ether b8:ac:6f:65:31:e5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.5/24 brd 192.168.1.255 scope global eth0
    inet6 fe80::baac:6fff:fe65:31e5/64 scope link 
       valid_lft forever preferred_lft forever
3: wlan0:  mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 00:21:6a:ca:9b:10 brd ff:ff:ff:ff:ff:ff
4: pan0:  mtu 1500 qdisc noop state DOWN 
    link/ether 92:0a:e7:31:e0:83 brd ff:ff:ff:ff:ff:ff
5: vmnet1:  mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:50:56:c0:00:01 brd ff:ff:ff:ff:ff:ff
    inet 192.168.121.1/24 brd 192.168.121.255 scope global vmnet1
    inet6 fe80::250:56ff:fec0:1/64 scope link 
       valid_lft forever preferred_lft forever
6: vmnet8:  mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:50:56:c0:00:08 brd ff:ff:ff:ff:ff:ff
    inet 192.168.179.1/24 brd 192.168.179.255 scope global vmnet8
    inet6 fe80::250:56ff:fec0:8/64 scope link 
       valid_lft forever preferred_lft forever

/proc/net/dev

The dev pseudo-file contains network device status information. This gives the number of received and sent packets, the number of errors and collisions and other basic statistics.
$ cat /proc/net/dev
Sample outputs:

Inter-|   Receive                                                |  Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
    lo:   20097     179    0    0    0     0          0         0    20097     179    0    0    0     0       0          0
vmnet8:       0       0    0    0    0     0          0         0        0      33    0    0    0     0       0          0
  pan0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0
 wlan0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0
  eth0: 592509534  623058    0    0    0     0          0      1053 122269656  401567    0    0    0     0       0          0
vmnet1:       0       0    0    0    0     0          0         0        0      34    0    0    0     0       0          0

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

22 comment

  1. In which distro are you using the ip command? I’m trying it in Ubuntu and it seems to be a command to manipulate routing

    1. @Chex, thanks! On Ubuntu, I was getting an error trying to run ‘ip -a’, but your command worked — and it’s very useful info.

  2. For wireless cards I find “iwconfig” useful. I used to have problems with a wireless adapter going offline, which I worked around with “iwconfig wlan0 power off” to turn off its power management feature.

  3. It would be most useful to correlate the HW info to the logical device name, such as the Broadcom NIC is eth1.

    1. Try ethtool or lspci it will map both along with driver name:

      ethtool -i eth0
      ethtool -i wlan0

      OR

      lspci -v -s deviceID

      Writing a shell script left as an exercise for the reader.

  4. At any point is this site going to post anything that isn’t basic common knowledge to any linux users that isnt a complete noob?

    Because if not, then I’m going to unsubscribe from your RSS feed.

    1. @root,

      I can not stop you or anyone else from unsubscribing to our RSS feed. The /faq/ section is for new users only so it has all sort of questions and answers. As you may have noticed that I’ve already started to display the difficulty level for each Q & A. I’m also working on rss feed for all three difficulties. So that users can only subscribe as follows:

      • Easy – for beginners.
      • Moderate – for Intermediate users.
      • Hard – for Advanced users.

      This is going to take a little more time as need some sort of coding and modification on my part. Hope this helps.

      1. ok, so idioms for the easy/intermediate/hard would be ubuntu/debian/all others? ^^

        Nah, but linux is no longer for those who actually are bothered to learn how to use a computer (as opposed to the in ‘noob-land’), learn how to use windows. Now, many of the windows users who are just ‘end users’ and not computer savvy, migrate to linux, and will inadvertedly land on ubuntu like distros.

        I recall on youtube, some user saying, I have been using Ubuntu for 6 months and consider myself fairly knowledgable, and then went on about DE if they are installable in other distros and what not. I don’t even know what it was, but it was so absurd, I am glad that person uttered Ubuntu and not linux, as clearly the person was clueless in the latter.

  5. @root
    I don’t suppose you have noticed that at least 99% of the worlds population are at least some variant of a linux ‘noob’. It would indeed be pointless to run a web site for just the 1% who are whizz kids as you would have very few visitors indeed.

    Also, I believe it should be ‘to any linux user who isn’t’

    Regards.

  6. I’ve clearly lost the plot a little myself, ‘at least’ and ‘indeed’ twice in above comment. Have to stop taking these tablets.

  7. In your scripts, the easiest way is to do something like this.

    for x in `/sbin/ifconfig | grep Link | awk ‘{print $1}’ | sort | egrep -v ‘inet6|lo’`
    do
    echo $x
    done

    Or you can /sbin/ifconfig $x | grep to extract and read the data into a variable to work on later.

  8. Here is a small code you can use in your scripts.

    for x in `/sbin/ifconfig | grep Link | awk ‘{print $1}’ | sort | egrep -v ‘inet6|lo’`
    do
    echo $x
    done

    You can replace echo $x with
    /sbin/ifconfig $x | grep (any property you are looking for) and read that into a variable.

  9. I think some of the posts are not being accepted in the comments, Vivek. Not sure why. I thought first it was something in my browser.
    I sure hope I didn’t have duplicates in the comments. :-)

    1. What distro?
      What specifics you are looking for?
      If you mean network settings for each card, depending on your distro, it can be found at

      For Redhat based distros
      /etc/sysconfig/network-scripts/ifcfg-[device Name]

      For Debian based distros
      /etc/network/interfaces

      For in depth, in detail information other settings about your network card, use ethtool.

      Run
      man ethtool

  10. hi all,

    I am new in linux.
    now I have problem with my X-Server installation.

    my machine used Red Hat V7,2
    and my card is used AGX3281.

    this is I did for replaced the old card, but I did with the same type.

    after I finished the install the X-server, and run startx,
    [[email protected] root]# startx

    xinit: No such file or directory (errno 2): no server “X” in PATH

    Use the — option, or make sure that /usr/X11R6/bin is in your path and
    that “X” is a program or a link to the right type of server
    for your display. Possible server names include:

    XFree86 XFree86 displays

    giving up.
    xinit: Connection refused (errno 111): unable to connect to X server
    xinit: No such process (errno 3): Server error.

    and when I start lspci
    [[email protected] root]# lspci
    00:00.0 Host bridge: Intel Corp.: Unknown device 2770 (rev 02)
    00:02.0 Display controller: Intel Corp.: Unknown device 2772 (rev 02)
    00:1c.0 PCI bridge: Intel Corp.: Unknown device 27d0 (rev 01)
    00:1c.1 PCI bridge: Intel Corp.: Unknown device 27d2 (rev 01)
    00:1c.2 PCI bridge: Intel Corp.: Unknown device 27d4 (rev 01)
    00:1c.3 PCI bridge: Intel Corp.: Unknown device 27d6 (rev 01)
    00:1d.0 USB Controller: Intel Corp.: Unknown device 27c8 (rev 01)
    00:1d.1 USB Controller: Intel Corp.: Unknown device 27c9 (rev 01)
    00:1d.2 USB Controller: Intel Corp.: Unknown device 27ca (rev 01)
    00:1d.3 USB Controller: Intel Corp.: Unknown device 27cb (rev 01)
    00:1d.7 USB Controller: Intel Corp.: Unknown device 27cc (rev 01)
    00:1e.0 PCI bridge: Intel Corp. 82801BAM PCI (rev e1)
    00:1f.0 ISA bridge: Intel Corp.: Unknown device 27b8 (rev 01)
    00:1f.2 IDE interface: Intel Corp.: Unknown device 27c0 (rev 01)
    00:1f.3 SMBus: Intel Corp.: Unknown device 27da (rev 01)
    0b:05.0 PCI bridge: Intel Corp.: Unknown device b154
    0b:0b.0 Ethernet controller: Intel Corp. 82541PI Gigabit Ethernet Controller (re
    v 05)
    0c:00.0 VGA compatible controller: ATI Technologies Inc: Unknown device 4c57
    0c:01.0 VGA compatible controller: ATI Technologies Inc: Unknown device 4c57
    0c:02.0 VGA compatible controller: ATI Technologies Inc: Unknown device 4c57
    0c:03.0 VGA compatible controller: ATI Technologies Inc: Unknown device 4c57
    0c:04.0 Host bridge: NEC Corporation Vrc5074 [Nile 4] (rev 03)

    I really need your advice for this issue.

    thanks before.

    best regards,

    Sunardy

Comments are closed.