Centos 7 how to fix -bash: ifconfig: command not found

If you installed CentOS 7 minimal you might see following error message when you try to use ifconfig to see your ip address:

[root@localhost ~]# ifconfig
-bash: ifconfig: command not found

If you search for the package it is in net-tools package

[root@localhost ~]# yum search ifconfig
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirror.iweb.ca
 * extras: mirror.csclub.uwaterloo.ca
 * updates: mirror.csclub.uwaterloo.ca
=================================================================== Matched: ifconfig ====================================================================
net-tools.x86_64 : Basic networking tools

In case you do not want to install additional package and simply to see your ip address you can use ip addr command

[root@localhost ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    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 qlen 1000
    link/ether 08:00:27:eb:6b:89 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.15/24 brd 10.0.0.255 scope global dynamic enp0s3
       valid_lft 85578sec preferred_lft 85578sec
    inet6 fe80::a00:27ff:feeb:6b89/64 scope link
       valid_lft forever preferred_lft forever

To install ifconfig

[root@localhost ~]# yum install net-tools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirror.iweb.ca
 * extras: mirror.csclub.uwaterloo.ca
 * updates: mirror.csclub.uwaterloo.ca
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.17.20131004git.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================
 Package                            Arch                            Version                                           Repository                     Size
==========================================================================================================================================================
Installing:
 net-tools                          x86_64                          2.0-0.17.20131004git.el7                          base                          304 k

Transaction Summary
==========================================================================================================================================================
Install  1 Package

Total download size: 304 k
Installed size: 917 k
Is this ok [y/d/N]: y
Downloading packages:
net-tools-2.0-0.17.20131004git.el7.x86_64.rpm                                                                                      | 304 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : net-tools-2.0-0.17.20131004git.el7.x86_64                                                                                              1/1
  Verifying  : net-tools-2.0-0.17.20131004git.el7.x86_64                                                                                              1/1

Installed:
  net-tools.x86_64 0:2.0-0.17.20131004git.el7

Complete!

and then you can use it

[root@localhost ~]# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::a00:27ff:feeb:6b89  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:eb:6b:89  txqueuelen 1000  (Ethernet)
        RX packets 11316  bytes 14098176 (13.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3224  bytes 264337 (258.1 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 0  (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
Tagged with: , , ,

Leave a Reply