Learn through the super-clean Baeldung Pro experience:
>> Membership and Baeldung Pro.
No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.
Last updated: March 18, 2024
It’s a good practice to verify that any newly installed hardware operates correctly. While there are many hardware modules in a computer, we’ll focus on the NIC (Network Interface Card).
In this tutorial, we’ll learn how to verify that the NIC has the correct network speed using two different ways: with standard Linux tools, and with the ethtool command.
We can check the speed of our NIC module by using the /sys pseudo-filesystem:
$ cat /sys/class/net/<interface>/speed
The advantage of this method is that we don’t need to install any external software tools.
Before we run the command, we need to know the network interface name. Two easy ways to find it are by using the ifconfig command or the ip command. Of course, we can always just list the interfaces within the /sys/class/net/ directory:
$ ls /sys/class/net
bond0 bonding_masters dummy0 eth0 lo sit0 tunl0
Once we know the network interface name, we can run the cat command on its speed file. For example, if the interface name is eth0, here’s the command to execute:
$ cat /sys/class/net/eth0/speed
100
The output is 100, which means that the speed of our networking interface is 100 Mbit/s.
Another way of checking the speed of our NIC is to use the ethtool command. ethtool is a useful utility to get the settings of the networking devices on a system.
As our main focus is the network speed, we’ll filter the ethtool output for the speed by using the grep command, for example:
$ sudo ethtool eth0 | grep Speed
Speed: 100Mb/s
The command above consists of multiple sub-commands. Let’s look at them in more detail:
As a result, we’ve obtained the speed of our NIC in a readable form. Further, it matches the information we already have from /sys/class/net/.
In this article, we learned how to find the speed of our NIC. Firstly, we looked at the standard Linux tool, where we checked the /sys/class/net/<interface>/speed file. And secondly, we learned how to use the ethtool command to filter out the same speed information.