Linux Ethtool Command Installation and Usage Guide

Visual depiction of a Linux terminal with the process of installing the ethtool command for network driver and hardware control

Are you struggling with managing your network interface on your Linux system? Just like a skilled mechanic has a set of tools to tune a car for optimal performance, Linux has the ‘ethtool’ command. This command is a powerful tool that can help you tune your network interface for optimal performance, but it can seem intimidating to install and use, especially for beginners. Luckily, the ‘ethtool’ command is readily available on most package management systems, which makes the installation process straightforward once you understand the steps involved.

In this guide, we will walk you through the process of installing and using the ‘ethtool’ command in Linux. We will provide instructions for both Debian and Ubuntu (which use the APT package management system) and CentOS and AlmaLinux (which use the YUM package manager). We will also delve into more advanced topics like compiling from source and installing a specific version of the command. Finally, we will provide guidance on how to use the command and verify that the correct version is installed.

So, let’s dive in and start tuning your network interface with the ‘ethtool’ command!

TL;DR: How Do I Install and Use the ‘ethtool’ Command in Linux?

In most Linux distributions, the ‘ethtool’ command comes pre-installed. However, if it’s not, you can install it in Debian based distributions like Ubuntu, by running the command sudo apt-get install ethtool. For RPM-based distributions like CentOS, you would run the command sudo yum install ethtool.

# For Debian based distributions like Ubuntu
sudo apt-get install ethtool

# For RPM-based distributions like CentOS
sudo yum install ethtool

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# The following NEW packages will be installed:
#   ethtool
# 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
# Need to get 0 B/123 kB of archives.
# After this operation, 395 kB of additional disk space will be used.
# Selecting previously unselected package ethtool.
# (Reading database ... 160837 files and directories currently installed.)
# Preparing to unpack .../ethtool_1%3a5.9-1_amd64.deb ...
# Unpacking ethtool (1:5.9-1) ...
# Setting up ethtool (1:5.9-1) ...
# Processing triggers for man-db (2.9.4-2) ...

This is a basic way to install the ‘ethtool’ command in Linux, but there’s much more to learn about installing and using ‘ethtool’. Continue reading for more detailed information and advanced usage scenarios.

Understanding and Installing the ‘ethtool’ Command

The ‘ethtool’ command in Linux is a versatile tool used for managing Ethernet devices. It allows you to view and change your network device settings, such as speed, port, autonegotiation, and many more. It’s an essential tool for system administrators who need to troubleshoot network issues.

Installing ‘ethtool’ with APT

On Debian-based distributions like Ubuntu, we use the Advanced Packaging Tool (APT) to install the ‘ethtool’ command. Here is how you can do it:

sudo apt update
sudo apt install ethtool

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# The following NEW packages will be installed:
#   ethtool
# 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
# Need to get 0 B/123 kB of archives.
# After this operation, 395 kB of additional disk space will be used.
# Selecting previously unselected package ethtool.
# (Reading database ... 160837 files and directories currently installed.)
# Preparing to unpack .../ethtool_1%3a5.9-1_amd64.deb ...
# Unpacking ethtool (1:5.9-1) ...
# Setting up ethtool (1:5.9-1) ...
# Processing triggers for man-db (2.9.4-2) ...

In the above code block, we first update the package list of the APT package manager using the sudo apt update command. Then we install the ‘ethtool’ command using the sudo apt install ethtool command.

Installing ‘ethtool’ with YUM

For RPM-based distributions like CentOS or Fedora, we use the Yellowdog Updater, Modified (YUM) to install the ‘ethtool’ command. Here is how you can do it:

sudo yum check-update
sudo yum install ethtool

# Output:
# Loaded plugins: fastestmirror, langpacks
# Loading mirror speeds from cached hostfile
#  * base: mirror.lug.udel.edu
#  * extras: centos.mirrors.tds.net
#  * updates: mirror.teklinks.com
# Resolving Dependencies
# --> Running transaction check
# ---> Package ethtool.x86_64 2:4.8-9.el7 will be installed
# --> Finished Dependency Resolution
# 
# Dependencies Resolved
# 
# ================================================================================
#  Package       Arch         Version                  Repository             Size
# ================================================================================
# Installing:
#  ethtool       x86_64       2:4.8-9.el7              base                 125 k
# 
# Transaction Summary
# ================================================================================
# Install  1 Package
# 
# Total download size: 125 k
# Installed size: 395 k
# Is this ok [y/d/N]: y
# Downloading packages:
# ethtool-4.8-9.el7.x86_64.rpm                                           | 125 kB  00:00:00     
# Running transaction check
# Running transaction test
# Transaction test succeeded
# Running transaction
#   Installing : 2:ethtool-4.8-9.el7.x86_64                                               1/1 
#   Verifying  : 2:ethtool-4.8-9.el7.x86_64                                               1/1 
# 
# Installed:
#   ethtool.x86_64 2:4.8-9.el7                                                               
# 
# Complete!

In the above code block, we first update the package list of the YUM package manager using the sudo yum check-update command. Then we install the ‘ethtool’ command using the sudo yum install ethtool command.

Installing ‘ethtool’ from Source Code

In some cases, you may want to install ‘ethtool’ from the source code. This can be useful if you want to modify the source code or if you want to install a specific version of ‘ethtool’ that is not available in your distribution’s package manager.

Here’s how you can do it:

wget https://git.kernel.org/pub/scm/network/ethtool/ethtool.git

# Output:
# --2022-03-23 00:00:00--  https://git.kernel.org/pub/scm/network/ethtool/ethtool.git
# Resolving git.kernel.org (git.kernel.org)... 198.145.29.83
# Connecting to git.kernel.org (git.kernel.org)|198.145.29.83|:443... connected.
# HTTP request sent, awaiting response... 200 OK
# Length: unspecified [application/x-git-packed]
# Saving to: ‘ethtool.git’

#     [ <=>                                 ] 0           --.-K/s   in 0s

# 2022-03-23 00:00:00 (0.00 B/s) - ‘ethtool.git’ saved [0]

In the above code block, we download the source code of ‘ethtool’ using the wget command.

Installing Different Versions of ‘ethtool’

From Source Code

If you want to install a specific version of ‘ethtool’ from the source code, you can do so by checking out the specific version using git. Here’s an example of how you can do it:

git clone https://git.kernel.org/pub/scm/network/ethtool/ethtool.git
cd ethtool
git checkout v5.10

# Output:
# Cloning into 'ethtool'...
# remote: Enumerating objects: 6851, done.
# remote: Counting objects: 100% (6851/6851), done.
# remote: Compressing objects: 100% (2866/2866), done.
# remote: Total 6851 (delta 5472), reused 5117 (delta 3961), pack-reused 0
# Receiving objects: 100% (6851/6851), 1.68 MiB | 1.39 MiB/s, done.
# Resolving deltas: 100% (5472/5472), done.
# Note: checking out 'v5.10'.

# You are in 'detached HEAD' state. You can look around, make experimental
# changes and commit them, and you can discard any commits you make in this
# state without impacting any branches by performing another checkout.

# If you want to create a new branch to retain commits you create, you may
# do so (now or later) by using -b with the checkout command again. Example:

#  git checkout -b <new-branch-name>

# HEAD is now at e8c7e9c... ethtool: release version 5.10

In the above code block, we first clone the ‘ethtool’ repository using the git clone command. Then we navigate to the ‘ethtool’ directory using the cd command. Finally, we check out the specific version (v5.10 in this case) using the git checkout command.

Using Package Managers

If you want to install a specific version of ‘ethtool’ using a package manager like APT or YUM, you can do so by specifying the version number in the install command. However, the availability of specific versions depends on the package manager and the distribution you are using.

Here’s an example of how you can install a specific version of ‘ethtool’ using APT:

sudo apt install ethtool=1:5.9-1

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# The following NEW packages will be installed:
#   ethtool
# 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
# Need to get 0 B/123 kB of archives.
# After this operation, 395 kB of additional disk space will be used.
# Selecting previously unselected package ethtool.
# (Reading database ... 160837 files and directories currently installed.)
# Preparing to unpack .../ethtool_1%3a5.9-1_amd64.deb ...
# Unpacking ethtool (1:5.9-1) ...
# Setting up ethtool (1:5.9-1) ...
# Processing triggers for man-db (2.9.4-2) ...

In the above code block, we install the ‘ethtool’ command version 1:5.9-1 using the sudo apt install ethtool=1:5.9-1 command.

Version Comparison

Different versions of ‘ethtool’ come with different features. For example, version 1:5.9-1 comes with enhanced support for setting and retrieving the master-slave role of a device, while version 1:5.10-1 comes with enhanced support for setting and retrieving the speed of a device.

Here’s a summary of the version comparison:

VersionKey Features
1:5.9-1Enhanced support for setting and retrieving the master-slave role of a device
1:5.10-1Enhanced support for setting and retrieving the speed of a device

Basic Usage of ‘ethtool’ and Verification

Using the ‘ethtool’ Command

Once you’ve installed ‘ethtool’, you can use it to view and modify the settings of your network interface. Here’s an example of how you can use ‘ethtool’ to view the settings of a network interface called ‘eth0’:

ethtool eth0

# Output:
# Settings for eth0:
#         Supported ports: [ TP MII ]
#         Supported link modes:   10baseT/Half 10baseT/Full 
#                                 100baseT/Half 100baseT/Full 
#                                 1000baseT/Half 1000baseT/Full 
#         Supported pause frame use: No
#         Supports auto-negotiation: Yes
#         Supported FEC modes: Not reported
#         Advertised link modes:  10baseT/Half 10baseT/Full 
#                                100baseT/Half 100baseT/Full 
#                                1000baseT/Half 1000baseT/Full 
#         Advertised pause frame use: Symmetric
#         Advertised auto-negotiation: Yes
#         Advertised FEC modes: Not reported
#         Speed: 1000Mb/s
#         Duplex: Full
#         Port: MII
#         PHYAD: 1
#         Transceiver: internal
#         Auto-negotiation: on
#         Supports Wake-on: pumbg
#         Wake-on: g
#         Current message level: 0x00000033 (51)
#                                drv probe ifdown ifup
#         Link detected: yes

In the above code block, we use the ‘ethtool’ command to view the settings of the ‘eth0’ network interface. The output shows the various settings of the network interface, such as the supported link modes, speed, duplex, auto-negotiation, and more.

Verifying the Installation

To verify that ‘ethtool’ has been installed correctly, you can use the ‘ethtool’ command with the ‘–version’ option. This will print the version of ‘ethtool’ that is currently installed on your system. Here’s how you can do it:

ethtool --version

# Output:
# ethtool version 5.9

In the above code block, we use the ‘ethtool –version’ command to print the version of ‘ethtool’ that is currently installed on our system. The output shows that we have ‘ethtool’ version 5.9 installed.

Exploring Alternative Methods for Network Interface Management

While ‘ethtool’ is a powerful tool for managing network interfaces in Linux, it’s not the only one. There are alternative commands like ‘ifconfig’ and ‘ip’ that can also be used to manage network interfaces. Let’s take a look at these alternatives and discuss their advantages, disadvantages, and when you might want to use them.

The ‘ifconfig’ Command

The ‘ifconfig’ command is one of the oldest tools for managing network interfaces in Linux. It allows you to configure and display network interface parameters.

Here’s an example of how you can use ‘ifconfig’ to display the details of a network interface called ‘eth0’:

ifconfig eth0

# Output:
# eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
#         inet 192.168.1.100  netmask 255.255.255.0  broadcast 192.168.1.255
#         inet6 fe80::20c:29ff:fe9c:4091  prefixlen 64  scopeid 0x20<link>
#         ether 00:0c:29:9c:40:91  txqueuelen 1000  (Ethernet)
#         RX packets 408639  bytes 546528779 (546.5 MB)
#         RX errors 0  dropped 0  overruns 0  frame 0
#         TX packets 168407  bytes 19550758 (19.5 MB)
#         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

In the above code block, we use the ‘ifconfig eth0’ command to display the details of the ‘eth0’ network interface. The output shows the various details of the network interface, such as the IP address, netmask, broadcast address, MAC address, and more.

However, ‘ifconfig’ is considered deprecated in many Linux distributions and has been replaced by the ‘ip’ command. It’s still available in many distributions, but it’s recommended to use the ‘ip’ command for newer systems.

The ‘ip’ Command

The ‘ip’ command is a newer tool for managing network interfaces in Linux. It’s part of the iproute2 package and is designed to replace the ‘ifconfig’ command.

Here’s an example of how you can use the ‘ip’ command to display the details of a network interface called ‘eth0’:

ip addr show eth0

# Output:
# 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
#     link/ether 00:0c:29:9c:40:91 brd ff:ff:ff:ff:ff:ff
#     inet 192.168.1.100/24 brd 192.168.1.255 scope global dynamic noprefixroute eth0
#        valid_lft 86283sec preferred_lft 86283sec
#     inet6 fe80::20c:29ff:fe9c:4091/64 scope link noprefixroute 
#        valid_lft forever preferred_lft forever

In the above code block, we use the ‘ip addr show eth0’ command to display the details of the ‘eth0’ network interface. The output shows the various details of the network interface, such as the IP address, netmask, broadcast address, MAC address, and more.

The ‘ip’ command provides more features and is more powerful than the ‘ifconfig’ command. It’s recommended to use the ‘ip’ command for managing network interfaces in newer Linux systems.

Choosing the Right Tool

When it comes to choosing between ‘ethtool’, ‘ifconfig’, and ‘ip’, it depends on your specific needs and the Linux distribution you are using. ‘ethtool’ provides a lot of features for managing Ethernet devices, while ‘ifconfig’ and ‘ip’ are more general tools for managing network interfaces.

Here’s a summary of the advantages and disadvantages of each tool:

ToolAdvantagesDisadvantages
ethtoolProvides a lot of features for managing Ethernet devicesNot as general as ‘ifconfig’ and ‘ip’
ifconfigSimple and easy to useConsidered deprecated in many Linux distributions
ipProvides more features and is more powerful than ‘ifconfig’More complex to use than ‘ifconfig’

In general, if you are managing Ethernet devices, ‘ethtool’ is the best tool to use. If you are managing network interfaces in general, the ‘ip’ command is the recommended tool to use. However, if you are working on an older system that doesn’t have the ‘ip’ command, the ‘ifconfig’ command can be used.

Troubleshooting Common ‘ethtool’ Issues

While ‘ethtool’ is a powerful command, as with any tool, you may encounter issues during its use. Below are a few common issues and their solutions.

‘ethtool’ Command Not Found

If you try to run ‘ethtool’ and receive a ‘command not found’ error, it means that ‘ethtool’ is not installed on your system, or it’s not in your system’s PATH.

To solve this issue, you can install ‘ethtool’ using your package manager. For example, on a Debian-based system, you can install ‘ethtool’ using the apt command:

sudo apt install ethtool

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# The following NEW packages will be installed:
#   ethtool
# 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
# Need to get 0 B/123 kB of archives.
# After this operation, 395 kB of additional disk space will be used.
# Selecting previously unselected package ethtool.
# (Reading database ... 160837 files and directories currently installed.)
# Preparing to unpack .../ethtool_1%3a5.9-1_amd64.deb ...
# Unpacking ethtool (1:5.9-1) ...
# Setting up ethtool (1:5.9-1) ...
# Processing triggers for man-db (2.9.4-2) ...

In the above code block, we install ‘ethtool’ using the sudo apt install ethtool command. After running this command, you should be able to use ‘ethtool’ without any issues.

‘ethtool’ Cannot Get Device Settings

If you try to use ‘ethtool’ to get the settings of a network interface and receive an error like ‘Cannot get device settings: No such device’, it means that the network interface you specified does not exist.

To solve this issue, you can use the ip addr command to list all network interfaces on your system and verify the name of the network interface you want to manage:

ip addr

# Output:
# 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
#     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
#     inet 127.0.0.1/8 scope host lo
#        valid_lft forever preferred_lft forever
#     inet6 ::1/128 scope host 
#        valid_lft forever preferred_lft forever
# 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
#     link/ether 00:0c:29:9c:40:91 brd ff:ff:ff:ff:ff:ff
#     inet 192.168.1.100/24 brd 192.168.1.255 scope global dynamic noprefixroute eth0
#        valid_lft 86283sec preferred_lft 86283sec
#     inet6 fe80::20c:29ff:fe9c:4091/64 scope link noprefixroute 
#        valid_lft forever preferred_lft forever

In the above code block, we use the ‘ip addr’ command to list all network interfaces on our system. The output shows that we have two network interfaces: ‘lo’ and ‘eth0’.

Considerations When Using ‘ethtool’

While ‘ethtool’ is a powerful tool, there are some considerations to keep in mind when using it:

  • ‘ethtool’ requires root privileges to modify network interface settings. When running ‘ethtool’ commands that modify settings, make sure to run them with ‘sudo’ or as the root user.
  • ‘ethtool’ only works with Ethernet devices. If you are managing other types of network interfaces, such as Wi-Fi or VPN interfaces, you may need to use other tools.
  • The changes made by ‘ethtool’ are not persistent across reboots. If you want to make the changes permanent, you need to add the ‘ethtool’ commands to a startup script or use a network manager that supports ‘ethtool’ settings.

Understanding Network Interface Management in Linux

Before delving deeper into the ‘ethtool’ command, it’s crucial to understand the concept of network interface management in Linux. Network interfaces are the gateways that allow your Linux system to connect and communicate with other devices or networks. These could be Ethernet interfaces, Wi-Fi interfaces, or even virtual interfaces like VPNs or loopbacks.

Why is Network Interface Management Important?

Managing network interfaces is a fundamental aspect of system and network administration. Whether it’s for setting up a server, connecting to a network, or troubleshooting network issues, understanding how to manage network interfaces is key.

ip link show

# Output:
# 1: lo: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
#     link/ether 00:0c:29:9c:40:91 brd ff:ff:ff:ff:ff:ff

In the above code block, the ‘ip link show’ command is used to display all network interfaces on the system. It shows two interfaces: ‘lo’, the loopback interface, and ‘eth0’, an Ethernet interface.

The Role of ‘ethtool’

This is where ‘ethtool’ comes in. ‘ethtool’ allows you to view and change the parameters of these network interfaces, such as speed, duplex setting, and auto-negotiation. This can be crucial when troubleshooting network issues or optimizing network performance.

For instance, you might want to check if your Ethernet interface is operating at its maximum speed, or you might want to enable or disable certain features for troubleshooting. With ‘ethtool’, you can do all of this and more.

ethtool eth0

# Output:
# Settings for eth0:
#         Supported ports: [ TP MII ]
#         Supported link modes:   10baseT/Half 10baseT/Full 
#                                 100baseT/Half 100baseT/Full 
#                                 1000baseT/Half 1000baseT/Full 
#         Supported pause frame use: No
#         Supports auto-negotiation: Yes
#         Supported FEC modes: Not reported
#         Advertised link modes:  10baseT/Half 10baseT/Full 
#                                100baseT/Half 100baseT/Full 
#                                1000baseT/Half 1000baseT/Full 
#         Advertised pause frame use: Symmetric
#         Advertised auto-negotiation: Yes
#         Advertised FEC modes: Not reported
#         Speed: 1000Mb/s
#         Duplex: Full
#         Port: MII
#         PHYAD: 1
#         Transceiver: internal
#         Auto-negotiation: on
#         Supports Wake-on: pumbg
#         Wake-on: g
#         Current message level: 0x00000033 (51)
#                                drv probe ifdown ifup
#         Link detected: yes

In the above code block, the ‘ethtool eth0’ command is used to display the settings of the ‘eth0’ Ethernet interface. It shows various settings such as the supported link modes, speed, duplex setting, and more.

In conclusion, the ‘ethtool’ command is a powerful tool for managing network interfaces in Linux. Understanding its use and functionality will allow you to effectively manage and troubleshoot your network interfaces.

The Bigger Picture: Network Interface Management and System Administration

Managing network interfaces with ‘ethtool’ is just one aspect of system administration and network performance. It’s a crucial part of ensuring that your system can communicate effectively with other devices and networks. However, there are other related concepts and tools that are worth exploring to gain a deeper understanding of network management in Linux.

Network Protocols and Their Importance

Network protocols define the rules for communication between devices over a network. They determine how data is transmitted, received, and interpreted. Understanding network protocols like TCP/IP, UDP, ICMP, and others can help you troubleshoot network issues and optimize network performance.

Network Security in Linux

Network security is a critical aspect of system administration. It involves protecting your system and data from unauthorized access, attacks, or disruptions. Tools like firewalls, VPNs, and intrusion detection systems can help you secure your network. Additionally, understanding concepts like encryption, authentication, and authorization can help you implement effective network security measures.

Further Resources for Network Interface Mastery

To deepen your understanding of network interface management in Linux, here are some resources that you might find useful:

  1. The Linux Documentation Project: An extensive collection of Linux documentation, including guides on networking and system administration.

  2. Linux Networking-HowTo: A comprehensive guide on networking in Linux, covering a wide range of topics from basic network configuration to advanced network troubleshooting.

  3. Linux Security: A resource site dedicated to Linux security, offering news, documentation, and guides on various Linux security topics.

Wrapping Up: Installing ‘ethtool’ for Effective Network Interface Management

In this comprehensive guide, we’ve journeyed through the installation and usage of the ‘ethtool’ command in Linux, an essential tool for network interface management.

We began with the basics, learning how to install ‘ethtool’ using package managers like APT and YUM. We then ventured into more advanced territory, exploring how to compile and install ‘ethtool’ from source code and how to use ‘ethtool’ to view and modify network interface settings.

Along the way, we tackled common challenges you might face when using ‘ethtool’, such as ‘command not found’ errors and issues with getting device settings, providing you with solutions and workarounds for each issue.

We also looked at alternative approaches to network interface management in Linux, comparing ‘ethtool’ with other commands like ‘ifconfig’ and ‘ip’. Here’s a quick comparison of these methods:

MethodFlexibilityComplexityModernity
ethtoolHighModerateHigh
ifconfigLowLowLow
ipHighHighHigh

Whether you’re just starting out with ‘ethtool’ or you’re looking to level up your network interface management skills, we hope this guide has given you a deeper understanding of ‘ethtool’ and its capabilities.

With its balance of flexibility, power, and modernity, ‘ethtool’ is a powerful tool for network interface management in Linux. Happy networking!