ethtool Commands and Examples

Introduction

Before we discuss ethtool commands and examples, let's briefly understand-What is ethtool?

The network command line tool used by Linux to set up Ethernet devices is known as the ethtool command. In the majority of Linux distributions, it comes pre-installed. Additionally, it gives information about Ethernet devices and lets Linux users change its settings.

In this tutorial, you will understand ethtool commands in Linux. We will also address a few FAQs on ethtool commands in Linux.

How to use the ethtool Command?

The basic syntax for the ethtool command is as follows:

Syntax:

The subsequent options are included in the syntax above:

ethtool [options] [device-name]
  • ethtool: The ethtool command is indicated by the ethtool Mian keyword.
  • options: Optional parameters for the ethtool command.
  • device-name: specifies the name of the Ethernet device.

For a brief description of the ethtool utility, including supported arguments, use the "man" command associated with it.

man ethtool

For more choices, scroll down the page. Let's move on to the numerous ethtool command examples.

Example 1: List Ethernet Device Settings

Before obtaining its settings, the user must be aware of the Linux system's available Ethernet device. Use the ip (internet protocol) command and the -a (address) flag to complete this task:

ip a

ens33 is the name of our Linux system's Ethernet device.

Use the ethtool command to list the details of the Ethernet device ens33 right away:

ethtool ens33

The "Settings for ens33" Ethernet device is highlighted in the output.

Example 2: Access the Driver Settings of Ethernet Device

The "Network Interface Card(NIC)" or "Ethernet device" driver parameters are provided via the "-i or -driver" flag of the ethtool command. The -driver argument is used with ethtool in this instance to obtain the ens33 driver settings:

ethtool --driver ens33

The output demonstrates that the ens33 device is using the e100 driver with version "5.15.0".

Example 3: List Network Interface Features

According to requirements, every Ethernet device supports a variety of characteristics and/or attributes. Use the -show-features flag with the ethtool command to obtain the desired Ethernet device features:

ethtool --show-features ens33

The aforementioned command lists all the functions that the ens33 ethernet device supports.

Example 4: Network Statistics of a Particular Ethernet Device

With the "-S or -statistics" option, the user can also discover network usage data, like we did above for interface ens33:

ethtool --statistics ens33

The "sent tx(transmitted)", "received rx(Received)", "collided" and "errors" packets of the interface ens33 are shown in the output of the aforementioned program.

Example 5: Customize the Specific NIC Parameters

The "speed", "duplex", and "Auto-negotiation" parameters on the Ethernet devices/network interface are easily editable with the ethtool command.

If the "ens33" is now operating in "Full" duplex mode at "1000Mb/s" speed and "Auto-negotiation" is enabled:

ethtool ens33

The -s (settings) command is available with the ethtool command. It is used to set the ens33 device speed to 10Mb/s, the duplex to half, and the auto-negotiation to off in this example.

sudo ethtool -s ens33 speed 10 duplex half autoneg off

The ens33 network interface's highlighted settings have been changed.

FAQs on ethtool commands and examples

How does the ethtool command work in Linux?

The ethtool command communicates directly with the network interface driver to retrieve or modify configuration and status information.

How can I install ethtool on my Linux system?

You can install ethtool using the package manager specific to your Linux distribution. For example, on Ubuntu, you can use apt with the command sudo apt install ethtool.

How do I use ethtool to display the status of a network interface?

To display the status of a network interface, run ethtool <interface_name>. For example, ethtool eth0 will display information about the Ethernet interface named eth0

Can I use ethtool to check the link status of an interface?

Yes, you can use ethtool to check the link status of an interface. The ethtool output will display whether the link is up or down.

How can I use ethtool to get information about the supported speeds and duplex modes?

You can use ethtool with the -a or -s option to retrieve information about the supported speeds and duplex modes of a network interface. For example, ethtool -a eth0 or ethtool -s eth0 will display the supported settings.

What are some common examples of using ethtool to configure network interfaces?

Some common examples of using ethtool to configure network interfaces include enabling or disabling features such as Wake-on-LAN, changing speed and duplex settings, and enabling or disabling flow control.

Is it possible to change the speed and duplex settings of a network interface with ethtool?

Yes, you can use ethtool with the -s option to change the speed and duplex settings of a network interface. For example, ethtool -s eth0 speed 100 duplex full sets the speed to 100 Mbps and duplex mode to full-duplex for interface eth0.

Conclusion

The network command line utility ethtool is supported by Linux and the majority of its distributions and is used to display and manage network interface devices.

It comes with a list of supported flags that alters its parameters and produces the necessary output in accordance with the requirements. The ethtool command has been briefly explained in this tutorial using real-world examples.