130

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.

  • 8
    Try sudo /sbin/ifconfig. – Ramesh Jul 19 '14 at 11:34
  • 4
    It isn't installed by default probably because it is regarded as obsolete: it is replaced by ip. – vinc17 Jul 19 '14 at 11:41
  • 6
    Try ip command. ifconfig is deprecated now – SHW Jul 19 '14 at 11:47
  • 1
    @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). – Gilles Jul 19 '14 at 12:01
  • 1
    @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. – Gilles Jul 19 '14 at 12:02
225

TL/DR: ifconfig is now ip 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.

Oh, you feel the command is too long? Easy! This is the same:

ip -s -c -h a
  • 8
    +1 for ip. net-tools has been deprecated in favor of iproute2. – HalosGhost Jul 19 '14 at 18:44
  • @Kiwy Oh, I would'nt mind if you'd add some details of that debate (but leave out some body related details), I actually never used it myself. Somebody could even file a bug report on the problems you see, then? – Volker Siegel Jul 22 '14 at 19:41
  • 1
    As in this answer, the equivalent ifconfig command is ip addr. – a coder Dec 4 '15 at 19:13
  • 1
    Yes - add the option -s (-stats, -statistics): ip -s addr – Volker Siegel Apr 26 '16 at 17:12
  • 1
    Also may be helpful Deprecated Linux networking commands and their replacements: dougvitale.wordpress.com/2011/12/21/… – Antonio Vinicius Menezes Medei Jun 6 '17 at 17:05
29

(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 

protected by Anthon Apr 18 '16 at 11:32

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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