199

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.

10
  • 14
    Try sudo /sbin/ifconfig.
    – Ramesh
    Jul 19, 2014 at 11:34
  • 7
    It isn't installed by default probably because it is regarded as obsolete: it is replaced by ip.
    – vinc17
    Jul 19, 2014 at 11:41
  • 13
    Try ip command. ifconfig is deprecated now
    – SHW
    Jul 19, 2014 at 11:47
  • 3
    @Ramesh No need for sudo: /sbin/ifconfig is enough if you want to see settings. You only need sudo if you want to change settings (and then sudo ifconfig is enough). Jul 19, 2014 at 12:01
  • 2
    @SHW Just because the author of the ip tool has decided that ifconfig was deprecated doesn't mean that the rest of the world has to stop using it. Jul 19, 2014 at 12:02

3 Answers 3

321

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
12
  • 8
    +1 for ip. net-tools has been deprecated in favor of iproute2.
    – HalosGhost
    Jul 19, 2014 at 18:44
  • 1
    As in this answer, the equivalent ifconfig command is ip addr.
    – a coder
    Dec 4, 2015 at 19:13
  • 1
    Yes - add the option -s (-stats, -statistics): ip -s addr Apr 26, 2016 at 17:12
  • 1
    Also may be helpful Deprecated Linux networking commands and their replacements: dougvitale.wordpress.com/2011/12/21/… Jun 6, 2017 at 17:05
  • 3
    Is deprecated because is ifconfig? They dont like the name? (yes i understand the point about functionality, but this is not a good reason to just remove the command) Why they dont just keep the command for compatibility with scripts in servers, for example creating a alias? Linux is starting to lost the point..., and more crap there are being done with linux, how systemd can be useful in a simple unix-like server? better migrate to freebsd before is too late? For example is practically impossible in a easy way to change the ip of some distros without restarting in text mode today! Nov 28, 2017 at 13:34
44

(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 
1
  • perfect answer...worked for me Sep 21, 2020 at 7:29
3

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.