1

How to Fix the "ifconfig: command not found" Error in Linux

 3 days ago
source link: https://www.makeuseof.com/fix-ifconfig-command-not-found-error-linux/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is damaged, please click the button below to view the snapshot at that time.

How to Fix the "ifconfig: command not found" Error in Linux

By Debarshi Das Published 10 hours ago

If you encounter the command not found error while using ifconfig, here's an easy way to solve it.

terminal with lots of code

ifconfig is a handy networking utility that fetches important data related to the network interface of your machine. It used to come pre-installed in all Linux distributions, that is until it was unanimously declared deprecated by developers due to lack of maintenance.

This is why calling the ifconfig command from the terminal returns an "ifconfig: command not found" error. If you still want to use ifconfig on your Linux system, you'll have to manually install it.

Install the net-tools Package in Linux

ifconfig command output

If you tried to install the ifconfig utility and failed, it's because ifconfig cannot be individually installed. It is included with the net-tools package. To be able to use the ifconfig command, you have to install the net-tools package first.

To install the package on Linux, fire up the terminal and run the command corresponding to the Linux distro that you're currently running:

On Debian/Ubuntu derivatives, run:

sudo apt install net-tools

On Arch-based systems, run:

sudo pacman -S net-tools

To install the net-tools package on Fedora, CentOS, and RHEL, issue the following command:

sudo dnf install net-tools

This should install the net-tools package on your Linux system, following which you will be able to run the ifconfig command without any errors.

How to Fix the Issue After net-tools Installation

ifconfig not found error

Installing net-tools should fix the issue, but in some cases, the "ifconfig: command not found" error might persist even with the net-tools package installed on your system.

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

Start off by verifying whether the ifconfig binary exists in the system binaries directory. You can check by either manually navigating to the /sbin directory with the cd command and looking for the ifconfig binary or automating the process with this one-liner:

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

The output of this command should be "ifconfig exists". If it returns an error or doesn't print the said phrase, you need to re-install the net-tools package. Once you get the desired output, check the contents of the PATH variable with this command:

echo $PATH

Wade through the output and look for /sbin in it. Chances are you will not find it. If that's the case, then export /sbin to your PATH variable with this command:

export PATH = $PATH:/sbin

Restart your Linux desktop after running this command. Upon boot-up, you should be able to use the ifconfig command flawlessly.

A Modern Alternative to ifconfig and net-tools

While you might find familiarity with ifconfig, it's recommended you move on to updated tools that offer the same features with better performance.

When the net-tools package was declared deprecated, it was replaced with the iproute2 software suite that includes better alternatives like ip, cstat, arpd, nstat, devlink, ss, tc, and more.

The iproute2 package should already be installed on your Linux machine, so don't worry about installation or configuration. You can simply run the commands.

To run the alternative to the ifconfig utility, type in this command:

ip a

You will find the output identical to that of the ifconfig command. You can get command-line help easily with the --help flag. Or if you want to learn more about each command, you can start by reading their man pages.

The Best Networking Commands for Linux

Linux is arguably the most popular operating system for servers and desktops alike. It never hurts to be familiar with a few useful commands that help with troubleshooting and configuring network settings. Since there are way too many networking commands to count, we've curated this list of some must-know Linux networking utilities.

About The Author
6223366c3c077-debarshidas.jpg?fit=crop&w=100&h=100

Debarshi Das (15 Articles Published)

I love breaking things and making things that help me in breaking things. When the screens are off, you can find me on the football ground or battling wits at the local chess club.

More From Debarshi Das

Subscribe to our newsletter

Join our newsletter for tech tips, reviews, free ebooks, and exclusive deals!

Click here to subscribe

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK