ifconfig is a handy network utility that retrieves important data related to your machine’s network interface. It was pre-installed in all Linux distributions, that is, until it was unanimously declared obsolete by the developers due to lack of maintenance.
This is why calling the ifconfig command from the terminal returns an error “ifconfig: command not found”. If you still want to use ifconfig on your Linux system, you will need to install it manually.
If you tried to install the ifconfig utility and failed, it’s because ifconfig cannot be installed individually. It is included with the net-tools wrap. To be able to use the ifconfig command, you must first install the net-tools package.
To install the package on Linux, launch the terminal and run the command for the Linux distribution you are currently using:
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, run the following command:
sudo dnf install net-tools
This should install the net-tools package on your Linux system, after which you can 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 need to manually update the PATH system variable and add the ifconfig binary to it.
Start by checking if the ifconfig binary exists in the system binaries directory. You can check by 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 does not print said sentence, you need to reinstall the net-tools package. Once you get the desired output, check the contents of the PATH variable with this command:
Scan the output and search for /sbin inside. Chances are you won’t find it. If so, 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 without issue.
Although you can get familiar with ifconfig, it is recommended that you upgrade to updated tools that provide the same functionality with better performance.
When the net-tools package was declared obsolete, it was replaced by the iproute2 software suite which includes better alternatives such as ip, cstat, arpd, nstat, devlink, ss, tc, etc.
The iproute2 package should already be installed on your Linux box, so don’t worry about installation or configuration. You can just run the commands.
To run the alternative to the ifconfig utility, type this command:
You will find the output identical to that of the ifconfig command. You can easily get command line help with the –to help flag. Or if you want to learn more about each command, you can start by reading their man pages.
The Best Network Commands for Linux
Linux is arguably the most popular operating system for servers and desktop computers. It never hurts to get familiar with a few useful commands that help with troubleshooting and configuring network settings. Since there are far too many networking commands to count, we’ve curated this list of some must-have Linux networking utilities.
10 Linux Network Commands and How to Use Them
About the Author