Sep 29, 2023 4 min read

How to Resolve "ifconfig: command not found" Error on Linux?

"ifconfig: command not found" error is and how to fix it with our step-by-step tutorial. "ifconfig" retrieves network information.

Resolve "ifconfig: command not found" Error on Linux
Table of Contents

Introduction

Before we begin talking about what is "ifconfig: command not found" error, let's briefly understand – What is ifconfig?

ifconfig is a useful networking tool that retrieves crucial information about your machine's network interface. It used to be pre-installed in every Linux distribution, but developers unanimously deemed it deprecated due to a lack of upkeep.

Because of this, the ifconfig command call from the terminal produces the error message "ifconfig: command not found". You'll need to manually install ifconfig on your Linux machine if you still want to use it.

If you attempted to install the ifconfig tool but were unable, it's because ifconfig cannot be installed separately. It is a part of the net-tools package. You must first install the net-tools package in order to use the ifconfig command.

In this tutorial, you will understand what is "ifconfig: command not found" error and how to fix it. We will also address a few FAQs on what is "ifconfig: command not found" error and how to fix it.

Open a terminal and enter the command appropriate to your current Linux distribution to install the package on Linux:

Run the following command on Debian/Ubuntu derivatives:

sudo apt install net-tools

Run the following command on Arch-based systems:

sudo pacman -S net-tools

Issue the following command to install the net-tools package on Fedora, CentOS, and RHEL:

sudo dnf install net-tools

Your Linux system should now have the net-tools package installed, which should resolve the "ifconfig: command not found" error. Calling the ifconfig command from the command line will now make it simple for you to use.

After installing net-tools, fix the "ifconfig: command not found" error.

Although installing net-tools should resolve the problem, occasionally the "ifconfig: command not found" error may still appear despite having the net-tools package set up on your computer.

In this case, you need to manually update and add the ifconfig binary to the system PATH variable.

To begin with, make sure the system binaries directory contains the ifconfig binary. You can find out by either manually using the cd command to access the /sbin directory and searching for the ifconfig binary, or automatically by using the following one-liner:

[[ -f /sbin/ifconfig ]] && echo "ifconfig exists"

This command should return "ifconfig exists" as its result. You must reinstall the net-tools package if it produces an error or fails to print the specified phrase. Once you get the desired result, use this command to see what is in the PATH variable:

echo $PATH

Search the output for /sbin as you go along. It's unlikely you'll locate it. If so, use the following command to export /sbin to your PATH variable:

export PATH=$PATH:/sbin

Once this command has been executed, restart your Linux system. You ought to have no problems using the ifconfig command right after boot-up.

A Modern Alternative to ifconfig and net-tools

Even while you might become accustomed to using ifconfig, it is advised that you move on to more recent tools that provide the same functions with improved performance.

The iproute2 software suite, which contains superior alternatives including ip, cstat, arpd, nstat, devlink, ss, tc, and more, took the place of the defunct net-tools package.

Don't worry about installing or configuring the iproute2 package; it should already be installed on your Linux system. You only need to execute the commands.

Enter the following command to launch the ifconfig utility's substitute:

ip a

The output is exactly the same as what you would get from the ifconfig command. Use the --help flag to quickly obtain command-line assistance. Or you can start by reading the man pages for each command if you want to learn more about it.

The Best Networking Commands for Linux

Undoubtedly, Linux is the most widely used operating system for both servers and desktops. Knowing a few helpful commands that assist with identifying and configuring network settings is always beneficial.

Although it would be impossible to list all the networking commands, you should be familiar with some essential Linux networking tools.

FAQs to "ifconfig: command not found" Error and How to Fix It

Why am I getting the "ifconfig: command not found" error? 

The ifconfig command is not included by default in some modern Linux distributions, including Ubuntu, CentOS, and Fedora. It has been replaced by the ip command.

How do I use the ip command as an alternative to ifconfig? 

Instead of using ifconfig, you can use the ip command. For example, to display information about network interfaces, you can use ip address show or ip a.

How do I install the net-tools package to fix the error? 

To install the net-tools package on Ubuntu or Debian based systems, run the command sudo apt-get install net-tools. On CentOS or Fedora, you can run sudo dnf install net-tools or sudo yum install net-tools.

Why was ifconfig deprecated? 

The ifconfig command was deprecated because it relies on outdated APIs and does not support advanced network configurations that are possible with the ip command.

Can I still use ifconfig on modern systems? 

Yes, you can still use ifconfig on systems where it is available or installed, but it is recommended to transition to using the newer ip command.

How do I check if the ifconfig command is installed on my system? 

You can check if the ifconfig command is installed by running the command ifconfig --version. If it is installed, it will display the version information; otherwise, you will receive the "command not found" error.

Are there any other alternatives to ifconfig? 

Yes, apart from the ip command, you can also use nmcli (NetworkManager command-line tool) or iwconfig (wireless interface configuration) to perform similar network-related tasks.

Conclusion

You now know what the "ifconfig: command not found" error is and how to fix it. If you have any queries or doubts, please leave them in the comment below. We'll be happy to address them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Blog - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.