“ifconfig: command not found” : Quick fixes

Windows users are familiar to ipconfig, a command used to acquire network interface configuration information and modify it. Linux have a similar tool, which is called ifconfig (stands for interfaces config).

Usually it is required to sign in as root or use sudo to be able to use ifconfig on a Linux machine.

Not only for acquiring information, ifconfig can also be used to modify/configure network interfaces. The program is a vital part of many operating systems as it is used in system startup scripts.

On newer Linux releases, when you try to call ifconfig from the command line, you may see an error pops up that says ifconfig: command not found or -bash: ifconfig: command not found. This article is going to help you understand why the error happens and what you can do to fix it.

What causes ifconfig command not found?

Basically the error means that there’s no such command named “ifconfig” found in the system. Since 2009, there have been plans to deprecate net-tools, which if config is a part of, due to the lack of maintenance. But for compatibility reasons, it was kept as part of the standard libraries until recently.

Starting from Debian Stretch and Ubuntu 18.04 and its derivatives such as Kali Linux, elementaryOS, net-tools along with ifconfig have been replaced with iproute2util package, which uses ip command by default. You will also find that ifconfig is missing by default on CentOS 7 and Fedora 18.

How to fix ifconfig command not found on Ubuntu/Debian

  • Open up your terminal
  • Type in the following command to install net-tools package (which includes ifconfig) : sudo apt-get install net-tools -y
  • The -y switch means apt will automatically accept any prompt that pops up.
  • Once the installation is done, you’ll be able to use ifconfig normally.

How to fix ifconfig command not found on CentOS

Similar to Ubuntu/Debian distro, you’ll need to install net-tools to get ifconfig back. In order to do it, run the command below in the terminal.

sudo yum install net-tools

If yum cannot find net-tools, maybe the repositories you have enabled might not have the package net-tools. You need to enable all CentOS global repositories.

sudo yum -y install epel-release
sudo yum clean all
sudo yum update all
sudo yum install -y net-tools

Fix ifconfig command not found after installing net-tools

Even with net-tools presence on your system, in a few cases, the problem still exist. You need to manually check whether the path for ifconfig binary is included in system PATH variable.

First you need to verify whether /sbin/ifconfig exists. You can either type the path directly into a terminal window or use this command:

[[ -f /sbin/ifconfig ]] && echo "ifconfig binary exists!"Code language: PHP (php)

Once you see ifconfig binary exists!, type this command into the terminal to see the current PATH variable

echo $PATHCode language: PHP (php)

Then inspect the output, if the output does not have /sbin in it, you need to manually add the path to system PATH variable using the following command

export PATH = $PATH:/sbinCode language: JavaScript (javascript)

Restart the machine, after that you should be able to use ifconfig normally.

Better ifconfig alternative

While you may become acquainted with ifconfig, it is advised that you move on to newer tools that provide the same functions with improved performance.

When the net-tools package was deemed obsolete, it was replaced by the iproute2 software suite, which contains superior replacements such as ip, cstat, arpd, nstat, devlink, ss, tc, and others.

The iproute2 package should already be installed on your Linux computer. In order to use it, simply execute its commands. For example, ip a is equivalent to ifconfig

<code>ip a</code>Code language: HTML, XML (xml)

The result will be identical to that of the ifconfig command. The --help parameter makes it simple to access command-line assistance.

Alternatively, if you want to learn more about each command, start by reading their man pages.

We hope that this tutorial provides useful information to help you solve the “ifconfig: command not found” error effectively and quickly.

If you spot any error in the article, or have a suggestion, please let us know via the comment section below.

You might also want to check out our guide on fixing other common “command not found” error messages with nodemonjavanpm or composer.

Leave a Comment