How to Fix ifconfig: command not found Error in Linux

Users of Linux often execute the “ifconfig” command to view and change the network interface. Other uses include viewing the IP address, hardware address, MTU, and more. Some users may face the error “bash: /usr/sbin/ifconfig: No such file or directory.” When the net-tools package is not present on the system, this error frequently occurs. For some users, it didn’t work even after installing the required packages.

Understanding the ‘ifconfig’ Command

 The ifconfig is short for “Interface configuration” which is responsible for configuring the network interfaces such as Ethernet, wireless cards, or virtual.  It plays a crucial role in a Linux system because it displays all the necessary data, such as IP address, netmask, and other network-related terms that users can later adjust. What causes the “Command ‘ifconfig’ not found”

The main cause of “ifconfig not found” is that the system does not have the net-tools package installed, which contains the ifconfig utility. Here’s how the error looks like.

ifconfig command not found
ifconfig command not found

Step-by-step guide to fixing the ‘ifconfig’ error

Every Linux user should know that a more powerful “ip” command with additional features has replaced the “ifconfig” command. The net-tools toolkit, which includes this command-line utility, may not be installed on the distro being used since it is deprecated. Therefore, the error “bash: /usr/sbin/ifconfig: No such file or directory” occurs.

Step 1: Install net-tools

To use the “ifconfig” command, users must install the net-tools toolkit, as done below.

$ sudo apt install net-tools
Installing net-tools

The above command will work for both Debian and Ubuntu. Use the following to install the net-tools toolkit if you use a different distro.

$ sudo yum install net-tools #For RHEL or CentOS
$ sudo dnf install net-tools #For Fedora 22+
$ sudo zypper install net-tools #For openSUSE

Step 2: Execute the ifconfig command

You should try reusing the command after installing the net-tools toolkit, and it should work fine.

$ ifconfig
ifconfig command

Follow step 3 if it is still not working.

Step 3: Add /sbin to system’s PATH variable

After installing the net-tools package, if the “ifconfig” command still doesn’t work, you should add ‘/sbin’ to the PATH variable of the system. This is necessary because the ‘/sbin’ directory is not included by default. You can execute the following command to add the directory to the system’s PATH variable.

$ export PATH="/sbin:/usr/sbin:${PATH}"
Adding ‘/sbin’ to PATH variable

You need to add this to the PATH variable because not adding it will require you to type the full path where the “ifconfig” command is located when executing it, which can be challenging for most users.. After executing the above command, make sure to restart the system for the changes to take effect.

Why the ifconfig command was depreciated?

Some developers claim that it was depreciated because of no development in the last 20 years. The reason for its deprecation was its inability to support newer networking technologies and its lack of versatility and flexibility compared to other available tools. We suggest that you switch to using the “ip” command, which these developers consider to be a more versatile and flexible tool than ifconfig and which provides many other options.
To use the “ip” command, follow this syntax.

ip [ OPTIONS ] OBJECT { COMMAND | help }

To get help on the “ip command” of Linux, refer to this man page or use the following help command.

$ ip help
ip help command

You can fix the error “bash: /usr/sbin/ifconfig: No such file or directory” on your system just like that, but since it is one of Linux’s old commands, we do not recommend using it. Although many users still use it, but why settle for less than the best?


Kevin Arrows

Kevin Arrows is a highly experienced and knowledgeable technology specialist with over a decade of industry experience. He holds a Microsoft Certified Technology Specialist (MCTS) certification and has a deep passion for staying up-to-date on the latest tech developments. Kevin has written extensively on a wide range of tech-related topics, showcasing his expertise and knowledge in areas such as software development, cybersecurity, and cloud computing. His contributions to the tech field have been widely recognized and respected by his peers, and he is highly regarded for his ability to explain complex technical concepts in a clear and concise manner.