The ifconfig command is used to view and configure network interfaces on Linux systems. However, in some Linux distributions like Ubuntu and Fedora, ifconfig may not be installed by default or could be deprecated.
If you try to run ifconfig and get an error like:
-bash: ifconfig: command not found
Here are some things you can try to troubleshoot and restore access to the ifconfig command on Linux:
Table of Contents
Check Alternative Commands
ip
Most modern Linux distributions use the ip command instead of ifconfig. The ip command has similar functionality to view and configure network interfaces.
To view interfaces, use:
ip addr show
To assign an IP address, use:
ip addr add 192.168.1.10/24 dev eth0
So in many cases, you can just use ip instead of ifconfig.
nmcli
Some systems also have nmcli available to view network configuration from NetworkManager.
For example, to show interfaces:
nmcli device status
Install ifconfig Package
If you still need or want to use ifconfig, try installing it directly:
Debian/Ubuntu
sudo apt install net-tools
RHEL/CentOS
sudo yum install net-tools
Fedora
sudo dnf install net-tools
After installing the net-tools package, ifconfig should be available.
Check System Path
In some cases, ifconfig could still be installed but not available in your system path.
Check if it exists with:
which ifconfig
If it shows nothing, try locating ifconfig manually:
locate ifconfig
If it exists in a non-standard path like /usr/sbin/ifconfig, you can either add that path to your environment, symlink ifconfig, or reinstall net-tools.
Use Static Build
If no ifconfig package is available for your distribution, you can download and compile a static build:
wget https://net-tools.sourceforge.io/releases/net-tools-2.10.tar.gz
tar xvzf net-tools-2.10.tar.gz
cd net-tools-2.10
./configure --prefix=/usr --static
make -C man
make -C po
make install
This will manually install a static ifconfig binary into your system.
Container/Chroot Issues
When running inside a container or chroot jail, the network interfaces and ifconfig binary may not be available.
Try running ifconfig from the host system instead or reconfigure networking to expose interfaces inside your container/jail.
Summary
- Use
ipornmclifor most network configuration tasks instead ofifconfig - Install the
net-toolspackage if you specifically need theifconfigcommand - Check system path and symlinks if
ifconfigseems to exist but command not found - Compile a static build as a last resort if no packages available
- Ensure proper container/chroot networking setup if applicable
