Table of Contents
If you encounter the command not found error while using ifconfig, here’s an easy way to solve it.
# ifconfig
-bash: ifconfig: command not found
Ifconfig tool
Ifconfig is a handy networking utility that fetches important data related to the network interface of your machine. It used to come pre-installed in all Linux distributions, that is until it was unanimously declared deprecated by developers due to lack of maintenance.
This is why calling the ifconfig command from the terminal returns an ifconfig: command not found error.
If you still want to use ifconfig on your Linux system, you’ll have to manually install it.
Install the net-tools Package in Linux
If you tried to install the ifconfig utility and failed, it’s because ifconfig cannot be individually installed. It is included with the net-tools package. To be able to use the ifconfig command, you have to install the net-tools package first.
Open up the terminal and run the command corresponding to the Linux distro that you’re currently running:
###Debian/Ubuntu
sudo apt -y install net-tools
###Fedora, CentOS, and RHEL 5/6/7
sudo yum -y install net-tools
###Fedora, CentOS, and RHEL 9 and higher.
sudo dnf -y install net-tools
The installation result in CentOS Stream 9.
# sudo dnf -y install net-tools
...
Installed:
net-tools-2.0-0.62.20160912git.el9.x86_64
Complete!
This should install the net-tools package on your Linux system, following which you will be able to run the ifconfig command without any errors.
ifconfig
# ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.10.5.91 netmask 255.255.0.0 broadcast 10.10.255.255
inet6 fe80::20c:29ff:fe8c:67d8 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:8c:67:d8 txqueuelen 1000 (Ethernet)
RX packets 20435 bytes 24541293 (23.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 7888 bytes 620630 (606.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Alternative to ifconfig and net-tools
While you might find familiarity with ifconfig, it’s recommended you move on to updated tools that offer the same features with better performance.
When the net-tools package was declared deprecated, it was replaced with the iproute2 software suite that includes better alternatives like ip, cstat, arpd, nstat, devlink, ss, tc, and more.
The iproute2 package should already be installed on your Linux machine, so don’t worry about installation or configuration. You can simply run the commands.
To run the alternative to the ifconfig utility, type in this command:
ip a
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:8c:67:d8 brd ff:ff:ff:ff:ff:ff
altname enp3s0
inet 10.10.5.91/16 brd 10.10.255.255 scope global noprefixroute ens160
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe8c:67d8/64 scope link noprefixroute
valid_lft forever preferred_lft forever