Dealing with the “ifconfig command not found” error and looking for a guide that can help you fix it? If yes, you have stumbled upon the right webpage.
All longtime Linux users may agree with me when I say ifconfig
is a go-to command to check the network interface configuration. This ifconfig
command has been seared deeply into our brains because of years of repetitive usage.
However, it would be a shock for Linux users if they tried running this command on any of the recently released Linux distros and received an error message stating, “ifconfig command not found.”
If that’s the case with you, you have landed on the right webpage.
This article covers detailed information about this error, why it occurs, and, most importantly, how to fix it.
So, without any further ado, let’s get started!
What is the ifconfig command?
ifconfig
is the OG system administration utility tool that is used to configure network interfaces. ifconfig
is quite similar to ipconfig
, a command used in Windows machines that lets you gather information about network interface configuration and configure it.
ifconfig
is considered one of the most useful Linux network tools as it fetches and displays detailed information about a network interface card, including IP Address, MAC Address, network status, and more. Besides that, it also lets you configure network interfaces.
However, the ifconfig
utility has been deprecated due to a lack of maintenance and active development, and, most importantly, in favor of a better and more powerful replacement, the ip
command from the iproute2
package. This could be why when you try to run the ifconfig
command, it shows the error message stating, “ifconfig command not found.”
Why Does the “ifconfig command not found” Error Occurs?
As the error message describes, you see this error because your machine doesn’t have the ifconfig
utility installed.
Here are some of the most common causes that may trigger this error:
#1. Net-tools Package is Missing
net-tools
is a package of tools that boasts several command-line tools, including ifconfig
, arp
, netstat
, and route
. This toolkit was developed to allow Linux users to configure network functionalities. However, the package hasn’t seen any development for a decade, and most Linux distros have even already deprecated it.
If this package isn’t installed on your Linux machine, that is the reason why you are dealing with the ifconfig command not found error.
#2. ifconfig Replaced with the ip Command
As mentioned earlier, the ifconfig
utility is a part of the net-tools
package. This package hasn’t seen any development in years, and therefore, many Linux distros have deprecated this package and replaced it with a more advanced and powerful iproute2
package.
If that’s the case, it also means that the ifconfig
command has been replaced with the ip
command.
#3. ifconfig is Missing by Default on CentOS/RHEL 7, Fedora 18, and Arch Linux
Since the net-tools
package hasn’t seen any active development from the Linux community, and some Linux distros have decided to replace this utility toolkit with the iproute2
package. These distros are CentOS/RHEL 7, Fedora 18, and Arch Linux.
If you are using these distros, not having the net-tools
package installed by default can be the reason the ifconfig
command isn’t working for you.
#4. Limited Privileges
If you are not using your Linux machine as an Admin or lack superuser privileges, you may see this ifconfig command not found error. This happens because the net-tools
toolkit gets installed in the root, and its files are stored in /sbin
and /usr/sbin
.
Some distros don’t include these directories for shell searches in the PATH environment for executable files. This may be the case if you have the net-tools
package installed, yet you are facing this error.
These are some of the reasons why you are dealing with the ifconfig command not found error.
Ways to Fix “ifconfig command not found” Error
This ifconfig command not found error can be quite frustrating, as it restricts you from configuring your network interfaces. The good thing here is that this error is quite easy to fix.
I have shared some of the best workarounds below that can help you fix this error –
Install net-tools
As mentioned earlier, this error primarily occurs when your Linux machine doesn’t have the net-tools
toolkit installed. Since the ifconfig
utility is a part of the net-tools
toolkit, you cannot install ifconfig
alone. You have to install the whole net-tools
toolkit instead.
Thankfully, you can easily install the net-tools toolkit by following these simple steps –
Step 1: Launch Terminal.
Step 2: Type the below-shared command and hit Enter. You will be asked to enter your root password to execute this command, as this command makes system-level changes and updates available packages.
sudo apt-get update
Step 3: After that, you need to install the net-tools
package. For that, enter the command shared below and hit Enter.
sudo apt-get install net-tool
s
This will install the net-tools
package. Upon a successful installation, check if the error persists by running the ifconfig
command again. If yes, you can use the command to manage your network interfaces.
Note that these commands won’t work on Linux distros except Debian, Ubuntu, Kali, and Raspbian.
So, if you use any other Linux distro on your computer, you can use the following commands –
- Alpine –
apk add net-tools
- Arch Linux –
pacman -S net-tools
- CentOS –
yum install net-tools
- Fedora –
dnf install net-tools
- RedHat –
dnf install net-tools
Installing the net-tools
toolkit on your Linux machine will mostly fix this error. However, if the error persists even after installing the net-tools
toolkit, you may have issues with PATH environment variables.
Resolve PATH Environment Variable Issues
As mentioned earlier, most distros don’t include directories where the ifconfig
is located in the PATH variable.
Since these directories aren’t included in the shell searches for executable files, whenever you run this command, the command doesn’t get recognized and shows the ifconfig command not found error.
To check whether the directory that contains the ifconfig
binary is included in the PATH, you can follow these simple steps:
Step 1: Launch Terminal.
Step 2: Type echo $PATH
and hit Enter. This will show you directories that are included in the PATH variable.
Check whether the directory that contains the ifconfig
binary is listed. If not, you have three options to resolve the PATH environment variable issue –
The first way you can fix the ifconfig
command error is by adding the directory that contains the ifconfig
binary to the PATH variable.
- Launch Terminal.
- Type the command shared below and hit Enter.
export PATH=”/sbin:/usr/sbin:${PATH}”
- Now, type the
ifconfig
command and hit Enter.
The second method includes running the ifconfig
command directly with the full path.
These are the steps that need to be followed to do the same –
- Launch Terminal.
- Type the command shared below and hit Enter.
/usr/sbin/ifconfig
The last method you can follow to fix this PATH variable issue is by running the ifconfig
command with the superuser privilege. This is the simplest and the easiest solution, but you’ll need to provide the root password.
For this –
- Launch Terminal.
- Type the command shared below and hit Enter.
sudo ifconfig command
That’s it. This is how you can resolve the PATH environment variable issue to fix the ifconfig command not found error.
Use the ip Command Instead of ifconfig
The ifconfig
utility has been deprecated, and a better replacement for this is undoubtedly the ip
utility from the iproute2
toolkit. Even some of the most popular distros have already replaced the net-tools
toolkit with iproute2
.
iproute2
toolkit supersedes net-tools
in many ways. For example, the iproute2
toolkit is much more powerful, reliable, and lightweight in comparison to net-tools
. Besides that, iproute2
boasts a better and more intuitive user interface than the net-tools
.
Above all, the reason I recommend you shift to the iproute2
toolkit is that the iproute2
toolkit has been under active development by the Linux community. The most recent development this toolkit has received was released on Feb 20, 2023.
Because of this continuous development, the iproute2
toolkit is compatible with some top-level network configuration tools. It can also be used to pull off tasks such as source-based routing, bonding, bridges, QoS, VLAN, etc., which are otherwise not possible with the net-tools
toolkit.
Therefore, it will be a great idea to switch to the iproute2
toolkit.
Final Words
There you have it – a detailed guide on how to fix the ifconfig command not found error.
ifconfig
is a very handy utility that you can use to configure and check network interfaces in Linux. However, the tool package has been deprecated and hasn’t seen even a minor development in over a decade.
Therefore, even though you can fix the error and use the ifconfig
command using the aforementioned methods, I recommend switching to the latest and more powerful ip
utility.
Next, check out Linux distros to know as a sysadmin and developer.