Ifconfig Command Not Found In CentOS 7

As we know “ifconfig” is used to show the details of the network card details, statistic and the situation in GNU/Linux systems but it is used and old way. If you want to use “ifconfig” command in your linux system you should install it from your os repository.

The error received is below.

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

Nowadays we use the command, which is given below, to show the IP address, Mac address and the status of the network interface.

ip addr

Sample output.

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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:b2:52:11 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.6/24 brd 192.168.2.255 scope global noprefixroute dynamic ens33
       valid_lft 3302sec preferred_lft 3302sec
    inet6 fe80::5018:6acc:485b:e277/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

To view the less information of the network interface you can use the following command.

ip link

Sample output.

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:29:b2:52:11 brd ff:ff:ff:ff:ff:ff

To view the detailed packages which flows on the network, enter the following code.

ip -s link

Sample output.

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    RX: bytes  packets  errors  dropped overrun mcast   
    0          0        0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 
    0          0        0       0       0       0       
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:29:b2:52:11 brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast   
    15206      154      0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 
    17767      103      0       0       0       0   

Get rid of the ifconfig error.

Now, let’s return the subject and install the package what we need to use ifconfig command in CentOS. Enter the code, which is given below, to your command line.

yum install net-tools -y
ifconfig install net-tools on centos 7
install net-tools on centos 7

Sample output.

Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: denizli.centos-mirror.guzel.net.tr
 * extras: mirror.fibersunucu.com.tr
 * updates: mirror.rackdc.com
base                                                                | 3.6 kB  00:00:00     
extras                                                              | 3.4 kB  00:00:00     
updates                                                             | 3.4 kB  00:00:00     
(1/4): base/7/x86_64/group_gz                                       | 166 kB  00:00:00     
(2/4): extras/7/x86_64/primary_db                                   | 201 kB  00:00:00     
(3/4): updates/7/x86_64/primary_db                                  | 5.0 MB  00:00:06     
(4/4): base/7/x86_64/primary_db                                     | 6.0 MB  00:00:09     
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.24.20131004git.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

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

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

Total download size: 306 k
Installed size: 918 k
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/net-tools-2.0-0.24.20131004git.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for net-tools-2.0-0.24.20131004git.el7.x86_64.rpm is not installed
net-tools-2.0-0.24.20131004git.el7.x86_64.rpm                       | 306 kB  00:00:00     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : net-tools-2.0-0.24.20131004git.el7.x86_64                               1/1 
  Verifying  : net-tools-2.0-0.24.20131004git.el7.x86_64                               1/1 

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

Complete!

We completed the installation and let’s check it out the code whether it works.

[root@centos ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.6  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::5018:6acc:485b:e277  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:b2:52:11  txqueuelen 1000  (Ethernet)
        RX packets 8802  bytes 12814700 (12.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5227  bytes 374060 (365.2 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
[root@centos ~]# 

The ifconfig article has completed, thanks for reading. If you want to read more about Linux you visit Linux category.

Reference articles:

https://www.centos.org/forums/viewtopic.php?t=47342

Leave a Reply

Your email address will not be published. Required fields are marked *