Skip to Content

3 Ways to fix ifconfig command not found in Linux

The “ifconfig: command not found” error typically means that the ifconfig binary is not installed or the path of the binary file is not under the $PATH.

So we can use the following 3 ways to fix this issue.

  • install ifconfig command through net-tools  package
  • run ifconfig command with full path
  • add the directory path of the ifconfig command to the $PATH

 

Install ifconfig command in Linux

The ifconfig command is a powerful tool used in Linux to check and configure network interfaces.

It can be used to check IP addresses, check connectivity, configure IP addresses, check packet network loss, and much more.

The ifconfig command is part of the net-tools package in Linux.

First, let’s check if you have installed net-tools package in your system.

On RedHat, Centos, and Fedora: rpm -qa|grep net-tools

On Ubuntu, Debian, and Mint: dpkg --list|grep net-tools

If you want to learn more about how to list installed package in Linux, you can refer to this article.

If the output is empty, it means that the package is not installed on your system. You will need to install it with:

On RedHat, Centos, Fedora: yum -y install net-tools

On Ubuntu, Debian, Mint: apt-get install net-tools

Check this article to get more info about how to install packages in Linux.

Once the installation is completed, try running ifconfig again and it should work.

Related: 5 ways to list installed packages in Linux

Run ifconfig command with full path

If the net-tools package is installed but the ifconfig command still won’t work, you can try running it with full path.

The full path of a command is the complete file system directory path that leads to the command’s executable file.

It is used to specify the exact location of the command when executing it in a terminal or command prompt.

For example, on a Linux system, the full path of the “ls” command might be “/bin/ls” and on a Windows system, the full path of the “cmd” command might be “C:\Windows\System32\cmd.exe”.

In Linux, type “which ifconfig” to find out the location of ifconfig command. Then run “/path/to/ifconfig” and it should work as expected.

You can run these commands:

On RedHat, Centos, Fedora: /usr/sbin/ifconfig

On Ubuntu, Debian, Mint: /sbin/ifconfig

Alternatively, you can also use the find command if you are not sure about the path of ifconfig command.

The find command can help locate the ifconfig command on a system, especially if the command’s path is not included in the system’s $PATH environment variable.

Here’s an example command you can use to search for the ifconfig command:

find / -name ifconfig 2>/dev/null

This command will search the entire file system starting from the root directory (/) for files with the name ifconfig, and redirect any error messages to /dev/null to suppress them. Once the command has finished running, it will output the path to the ifconfig command.

Note that depending on the size of your system, this search could take some time to complete

By using the full path of the command, you are specifying the exact location of the command to the system, which ensures that the correct version of the command is run, even if there are multiple versions of the command available on the system.

Add ifconfig binary to $PATH location

The third option to fix this problem is to add your ifconfig binary to the $PATH location.

The $PATH variable is an environment variable that contains the list of directories where your system looks for executables.

You can use echo $PATH command to check the current value of this variable.

If the directory of ifconfig binary is not listed, you will get “ifconfig command not found” error.

In this case, you can add the ifconfig directory path to the $PATH variable.

On RedHat, Centos, Fedora: export PATH=$PATH:/usr/sbin/

On Ubuntu, Debian, Mint: export PATH=$PATH:/sbin/

Once you have updated the $PATH variable, try running ifconfig again and it should work.

Tips: different users use different $PATH configuration. You can try to switch to root user to try ifconfig command.

That might work because the $PATH for root user has more directories. 

ifconfig command alternative

The ifconfig command has been deprecated and is no longer being actively maintained. It may not be installed by default on some systems. We can use ip command instead.

The ip command can perform all the functions of the ifconfig command, but it can also do much more. It allows you to manage routing tables, tunnels, and more.

The ip command is available in most modern Linux distributions. For example, if we need to show ip addr, we can run ip addr command.

Here is another example.

The ip route show command is used to display the routing table on a Linux system. The routing table contains information about how packets should be routed between different networks, and it is used by the system to determine how to forward network traffic. 

If you want to get more info about ip command, check out this post.

We hope you found this blog post helpful and that it helped you solve your problem. If you have any questions or comments, please feel free to leave them in the comment section below. Thanks for reading!

Related: 5 ways to install package in Linux