ifconfig is a handy network utility that fetches important data regarding your computer’s network interface. It used to come pre-installed in all Linux distributions, until it was unanimously declared deprecated by developers due to lack of maintenance.
This is why calling the ifconfig command from the terminal returns the “ifconfig: command not found” error. If you still want to use ifconfig on your Linux system, you will have to install it manually.
If you tried to install the ifconfig utility and failed, it is because ifconfig cannot be installed individually. It is included with net-tools parcel. To be able to use the ifconfig command, you must first install the net-tools package.
To install the package on Linux, fire up the terminal and run the command corresponding to the Linux distribution you are 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 will install the net-tools package on your Linux system, then you should be able to run the ifconfig command without any errors.
Installing net-tools should fix the problem, but in some cases the “ifconfig: command not found” error may 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 by verifying if the ifconfig binary exists in the system binaries directory. You can check by manually navigating to /sbin directory with the cd command and search for the ifconfig binary, or automate 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 reinstall the net-tools package. Once you get the desired output, check the contents of the PATH variable with this command:
Skim through the output and search /sbin in there. Chances are you won’t 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. On startup you should be able to use the ifconfig command perfectly.
While you may be familiar with ifconfig, you should switch to updated tools that offer similar features with better performance.
When the net-tools package was deprecated, it was replaced by the iproute2 suite which included better alternatives like ip, cstat, arpd, nstat, devlink, ss, tc, etc.
The iproute2 package is already pre-installed on your Linux machine, so don’t worry about installation or configuration. You can simply run the commands.
To run an alternative to the ifconfig utility, enter the following command:
You should see the same output as the ifconfig command. You can easily get command line help with –Help flag. Or if you want to learn more about each command, you can start by reading their man pages.
Best Network Commands for Linux
Linux is arguably the most popular operating system for servers and desktop computers. It never hurts to be familiar with some helpful commands that help troubleshoot and configure network settings. Since there are so many network commands to count, we’ve curated this list of some of these must-know Linux networking utilities.
10 Linux network commands and how to use them
About the author
https://www.makeuseof.com/fix-ifconfig-command-not-found-error-linux/ command not found” Error in Linux