In this article, we will see how to solve "-bash: ifconfig: command not found"
error in CentOS/Redhat 7/8. If you are using CentOS/Redhat from long time then you might be used to ifconfig
command to check and troubleshoot Linux network issues. But the same if you try to do from CentOS/Redhat 7 onwards then you will end up getting the same error as this tool will not be available.
This is due to the reason that ifconfig
command is deprecated from CentOS/RedHat 7 onwards. Instead ip
command is available to check network interface details and to perform other Linux networking operations. Still if you want to use ifconfig
command then you need to follow below given instructions.
Solved "-bash: ifconfig: command not found" error
While it is very common to get "-bash: ifconfig: command not found"
error in CentOS/ Redhat 7/8 due to the reason that ifconfig
command is not available by default. Instead its successor ip
command is available now. You can check all the network interface details by using ip addr sh command.
NOTE:
root
user to run all the below commands. You can use any user with sudo
access to run all these commands. For more information Please check Step by Step: How to Add User to Sudoers to provide sudo
access to the User.[root@localhost ~]# ip addr sh 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: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 08:00:27:0b:3e:c5 brd ff:ff:ff:ff:ff:ff inet 192.168.29.75/24 brd 192.168.29.255 scope global dynamic enp0s3 valid_lft 3394sec preferred_lft 3394sec
So to deal with the error you need to install net-tools
package which is the source distribution package for ifconfig
command.
[root@localhost ~]# yum install net-tools Loaded plugins: fastestmirror Determining fastest mirrors * base: mirrors.piconets.webwerks.in * extras: mirrors.piconets.webwerks.in * updates: centos.mirrors.estointernet.in base | 3.6 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/2): extras/7/x86_64/primary_db | 242 kB 00:00:00 (2/2): updates/7/x86_64/primary_db | 8.8 MB 00:00:22 Resolving Dependencies --> Running transaction check ---> Package net-tools.x86_64 0:2.0-0.25.20131004git.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================= Package Arch Version Repository Size ============================================================================================================================================================= Installing: net-tools x86_64 2.0-0.25.20131004git.el7 base 306 k Transaction Summary ============================================================================================================================================================= Install 1 Package Total download size: 306 k Installed size: 917 k Is this ok [y/d/N]: y Downloading packages: net-tools-2.0-0.25.20131004git.el7.x86_64.rpm | 306 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : net-tools-2.0-0.25.20131004git.el7.x86_64 1/1 Verifying : net-tools-2.0-0.25.20131004git.el7.x86_64 1/1 Installed: net-tools.x86_64 0:2.0-0.25.20131004git.el7 Complete!
Again if you try to run ifconfig
command, then you should see output like below where all the information about both enp0s3
and lo
network interface will be shown. This confirms successful installation of ifconfig command and now you should not see "-bash: ifconfig: command not found"
error again . To know more about ifconfig
command, check its Man Page.
[root@localhost ~]# ifconfig enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.29.75 netmask 255.255.255.0 broadcast 192.168.29.255 ether 08:00:27:0b:3e:c5 txqueuelen 1000 (Ethernet) RX packets 100 bytes 11269 (11.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 69 bytes 10035 (9.7 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