ifconfig command not found

I’ve just installed CentOS7 as a virtual machine on my mac (osx10.9.3 + virtualbox) .Running ifconfig returns command not found. Also running sudo /sbin/ifconfig returns commmand not found. I am root. The output of
echo $PATH is as below.

/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/robbert/.local/bin:/home/robbert/bin

Is my path normal? If not, how can I change it?

Also, I don’t have an internet connection on virtual machine yet, maybe that’s a factor.

Asked By: RobSeg

||

TL/DR: ifconfig is now ip a. Try ip -s -c -h a.

Your path looks OK, but does not include /sbin, which may be intended.

You were probably looking for the command /sbin/ifconfig.

If this file does not exist (try ls /sbin/ifconfig), the command may just be not installed.

It is part of the package net-tools,
which is not installed by default, because it’s deprecated
and superseded by the command
ip from the package iproute2.

The function of ifconfig without options is replaced by ip specifying the object address.

ifconfig

is equivalent to

ip addr show

and, because the object argument can be abbreviated and command defaults to show, also to

ip a

The output format is somewhat different:

$ ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:10553 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10553 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:9258474 (9.2 MB)  TX bytes:9258474 (9.2 MB)
[ ... ]

and

$ ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    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
[ ... ]

Note the output is more terse:
It does not show counts of packets handled in normal or other ways.

For that, add the option -s (-stats, -statistics):

$ ip -s addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    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
    RX: bytes  packets  errors  dropped overrun mcast
    74423      703      0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    74423      703      0       0       0       0

But what you actually want to see may be this:

$ ip -stats -color -human addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    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
    RX: bytes  packets  errors  dropped overrun mcast
    74.3k      700      0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    74.3k      700      0       0       0       0

It shows counts with suffixes like 26.1M or 79.3k and colors some relevant terms and addresses.

If you feel the command is too long, use the short options:
This is equivalent:

ip -s -c -h a
Answered By: Volker Siegel

(verified) The default minimal install of CENTOS 7 does not install net-tools.

(verified) ‘ifconfig’ command will become available on installing package net-tools

-How to install net-tools through yum for the not so linux experts.

1) have a root privilege shell or be on the sudo list.

2a) At a root shell prompt (#)

yum install net-tools

2b) User account on the sudo list

sudo yum install net-tools

If the package is installed it will state so and exit yum. (Then it sounds like a path issue).
If not installed yum will prompt the user to continue after a few local / network package checks. The install will (should) take but a moment.. presto ifconfig is now installed.

If you feel adventurous..
The equivalent of using ifconfig in displaying the interface / address information using ip

ip addr 
Answered By: jsd

Since everyone else has already provided the answer to finding ifconfig or available alternatives, I will provide some generic tips on how to get out of this situation because this is not the first or last time one would need to get hold of a command/package/utility on their system (basically I am teaching a person how to fish :). The instructions are for RHEL/CentOS.

Scenario 1: If that command already exists on another system:

  1. which ifconfig <- find the location of ifconfig. It might say /usr/sbin/ifconfig
  2. rpm -qf /usr/sbin/ifconfig <- This will give you the name of the rpm (like net-tools-2.0.0)
  3. sudo yum install net-tools <- Run this on your system to install the package.

Scenario 2: If you don’t have another reference system, run the command yum whatprovides ifconfig. This will tell you the package name that contains the command and, if it already exists on your system, the path of the command. If the package doesn’t exist, you just need to run sudo yum install to install it and you should be on your way.

These are generic instructions to find and install any package. I am not going into details about repos/other distros and other stuff here, so that you can get started.

HTH.

Answered By: Hopping Bunny
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.