ifconfig command not found
Solution 1
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
Solution 2
(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
Solution 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:
which ifconfig
<- find the location of ifconfig. It might say /usr/sbin/ifconfigrpm -qf /usr/sbin/ifconfig
<- This will give you the name of the rpm (like net-tools-2.0.0)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.
RobSeg
Updated on September 18, 2022Comments
-
RobSeg almost 2 years
I've just installed CentOS7 as a virtual machine on my mac (osx10.9.3 + virtualbox) .Running
ifconfig
returns command not found. Also runningsudo /sbin/ifconfig
returns commmand not found. I am root. The output ofecho $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.
-
Ramesh almost 10 yearsTry
sudo /sbin/ifconfig
. -
celtschk almost 10 yearsDid you perhaps mean
/sbin/ifconfig
? Looking at my system, I can't find an/sbin/config
either. BTW, what do you get fromls /sbin/ifconfig
? -
RobSeg almost 10 yearsThank you, I tried, it returns command not found. I guess the net-tools package is absent. I'll try to fix my internet connection first to download net-tools.
-
RobSeg almost 10 yearsYes, I meant /sbin/ifconfig. ls /sbin/ifconfig doesn't exist so I'll have to install that. I guess that's it. I think it's very weird that it didn't install by default.
-
vinc17 almost 10 yearsIt isn't installed by default probably because it is regarded as obsolete: it is replaced by
ip
. -
klerk almost 10 yearswhat
locate ifconfig
says -
SHW almost 10 yearsTry
ip
command. ifconfig is deprecated now -
Gilles 'SO- stop being evil' almost 10 years@Ramesh No need for
sudo
:/sbin/ifconfig
is enough if you want to see settings. You only needsudo
if you want to change settings (and thensudo ifconfig
is enough). -
Gilles 'SO- stop being evil' almost 10 years@SHW Just because the author of the
ip
tool has decided thatifconfig
was deprecated doesn't mean that the rest of the world has to stop using it. -
SHW almost 10 yearsI was under impression that Linux community had deprecated
ifconfig
. Anyway, thanks for enlightening :)
-
-
Jakob Bennemann almost 10 years+1 for
ip
.net-tools
has been deprecated in favor ofiproute2
. -
Volker Siegel almost 10 years@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?
-
Gbo over 8 years
-
Volker Siegel over 8 years@acoder Thanks for the useful hint, I expanded the answer accordingly.
-
Stefan Krüger s-light about 8 yearsis there a ip xxx command for receiving the RX and TX packets like shown in ifconfig?
-
Volker Siegel about 8 yearsYes - add the option
-s
(-stats
,-statistics
):ip -s addr
-
Amitav Pajni almost 8 yearsThose colors look terrible on a dark background.
-
Antônio Medeiros about 7 yearsAlso may be helpful Deprecated Linux networking commands and their replacements: dougvitale.wordpress.com/2011/12/21/…
-
Luciano Andress Martini over 6 yearsIs 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!
-
Volker Siegel over 4 years@MatejJ With "external" you mean "from the public internet" I asssume. This address is most probably managed by your router, by using NAT. That means the external address is the address of the router. The router forwards specific connections to your computer, which has a local address. So what seems to be the external address of your computer is actually not an address of your computer at all. Your computer does not even know that it has one. It could have multiple, too.
-
Matej J over 4 yearsSorry i meant ip address which is visible in lan network..
-
TAMIM HAIDER almost 4 yearsperfect answer...worked for me