How to Fix “ifconfig command not found” in Linux

As a Linux system administrator or power user, you likely use the ifconfig command on a regular basis to view network interface configurations. However, you may encounter the frustrating “ifconfig: command not found” error when trying to run it.

This common issue occurs because the ifconfig utility is not installed by default on some Linux distributions anymore. But the good news is, fixing this problem is quite simple!

In this article, I’ll explain step-by-step how to install ifconfig and permanently enable the command on your system. I’ll also cover some extra troubleshooting tips in case you run into any other issues getting ifconfig to work properly.

Why Am I Seeing “ifconfig command not found”?

First, let’s discuss why this error happens in the first place.

The ifconfig command has been around for decades and was previously included in most Linux distros by default. However, in recent years many distributions like Ubuntu and Fedora have replaced it with a newer command called ip.

The ip tool performs similar functions to ifconfig such as displaying network configuration details. But it’s considered more modern and versatile.

So for that reason, newer Linux versions no longer install ifconfig automatically. That’s why running the standard ifconfig command results in a “command not found” error.

However, many admins still prefer using good old ifconfig out of habit or convenience. So let’s look at how to quickly get ifconfig set up on your system.

Method 1: Installing ifconfig Package

The easiest way to enable the ifconfig command is by installing its package that contains the ifconfig binary.

On Debian/Ubuntu

For Debian-based distros like Ubuntu, you just need to use apt:

sudo apt update
sudo apt install net-tools

The ifconfig tool is bundled in the net-tools package, so this automatically enables the ifconfig command.

On CentOS/RHEL

On RHEL-based distros including CentOS, use yum to install net-tools:

sudo yum update
sudo yum install net-tools

On Fedora

For RPM-based distros like Fedora, install net-tools using dnf:

sudo dnf update 
sudo dnf install net-tools

And that’s it! Installing the net-tools package makes the ifconfig command accessible on all major Linux distributions.

Alternatively, you can enable ifconfig by creating a symbolic link to the ip command, which has similar functionality.

Here is how to set up a symlink for ifconfig manually:

sudo ln -s /usr/sbin/ip /usr/bin/ifconfig

Now running ifconfig will execute the ip tool instead, essentially giving you access to ifconfig again!

The benefit here is you don’t need to install any additional packages. However, the output format of ip isn’t exactly the same as the traditional ifconfig command.

Still, creating a quick symlink gets ifconfig working again on your system. And you always have access to the full ip tool for more advanced network management.

Testing and Verifying ifconfig

After installing ifconfig using either method above, verify it is now enabled by running:

ifconfig

You should see the standard output displaying details about your network interfaces:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.14  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::20c:29ff:fe98:c671  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:98:c6:71  txqueuelen 1000  (Ethernet)
        RX packets 2348910  bytes 1549824065 (1.4 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1225196  bytes 86176542 (82.1 MiB) 
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

As long as the output displays without any errors, you have successfully made ifconfig available again using one of the methods above!

Troubleshooting Other Issues

On some Linux systems, you may run into additional problems trying to get ifconfig running properly even after installing it. Here are some things to check:

1. Check path variable:

Make sure your $PATH contains the directory where ifconfig is installed. Usually this is /usr/sbin or /sbin.

2. Check permissions:

The ifconfig binary requires root privileges to run. So you need to use sudo to test it, unless you are logged in as the root user.

You can also check the file permissions with ls -l /path/to/ifconfig and modify if needed.

3. Check linking errors:

Some tools like libc may be missing that are required for ifconfig to run. Use ldd to check for broken links:

ldd /usr/sbin/ifconfig

And reinstall any missing libraries reported.

4. Reinstall net-tools package

As a last resort, completely remove the net-tools package and reinstall it from scratch:

sudo apt remove net-tools
sudo apt update
sudo apt install net-tools

Hopefully with some debugging, you’ll have the trusty ifconfig command working correctly on your system once again!

Conclusion

Although ifconfig has largely been deprecated, many Linux admins still find it useful for examining network configurations.

When running into a “command not found” error, first install the net-tools package containing ifconfig using your distro’s package manager.

Alternatively, create a symbolic link from ifconfig to ip for basic functionality.

With ifconfig enabled again on your system, you can easily view your NIC names, IP addresses, subnet masks, and more. No need to struggle with the newer ip command if you prefer using old reliable ifconfig instead!

Fixing the “ifconfig not found” error ultimately comes down to properly installing its package or symlinking the ip command. With the simple solutions in this guide, you’ll be back to using ifconfig in no time.

Leave a Comment