“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.

Why ifconfig command not found happens?

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 and type in the following command to install net-tools package and ifconfig that comes along with it.

sudo apt-get install net-tools -y
Code language: JavaScript (javascript)

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 by typing the command below into the terminal.

sudo yum install net-tools

If yum cannot find net-tools, maybe 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 $PATH
Code 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:/sbin
Code language: JavaScript (javascript)

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

Click to rate this post!
[Total: 46 Average: 4.9]

Leave a Comment