15

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/config returns commmand not found. This is echo $PATH

/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.

Please bear in mind i'm a student and very new to certain terminology.

Aman Aggarwal
  • 17,619
  • 9
  • 53
  • 81
RobSeg
  • 985
  • 4
  • 14
  • 37
  • `bash: ifconfig: command not found` --> the command is deprecated, see [ifconfig and locate command not found, `bash: ifconfig: command not found`](https://unix.stackexchange.com/questions/631542/ifconfig-and-locate-command-not-found) on Unix & Linux Stack Exchange where the question belongs. – questionto42 Jul 22 '22 at 21:20

8 Answers8

45

ifconfig exists in the net-tools package which may not be installed by default;

sudo yum install net-tools

When the package is installed, it will exist as /sbin/ifconfig.

Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
  • 2
    if ifconfig does not exist how is an ip address configured to allow yum to operate? – waTeim Jul 19 '14 at 11:29
  • Thank you very much, that's probably it. Although yum install returns cannot find a valid baseurl, I guess I don't have an internet connection to virtual machine. I'll look into that first. Any help on troubleshooting internet connection is also appreciated. – RobSeg Jul 19 '14 at 11:33
  • Perfect! Nice answer. – T-Heron Jun 05 '19 at 17:40
25

I too had same problem after installation of RHEL,CentOS. Resolved with the following. Type:

vi ~/.bashrc

Press i key to go to insert mode. Write the following to the end of this file

export PATH=$PATH:/sbin

then exit Vi by press :wq!

At the terminal type below command to reflect our changes.

source ~/.bashrc

Now type the command ifconfig , it should work.

Vic
  • 2,655
  • 3
  • 18
  • 28
user355859
  • 369
  • 3
  • 3
23

The ifconfig command has been deprecated so it is not installed by default on many new distros. The replacement is

ip address

You can write a shortcut

ip a

Very handy :)

Paglian
  • 6,162
  • 3
  • 26
  • 20
4

In some cases. Installing net-tools is not enough directly.

Try this:

apt install net-tools

nano ~/.bashrc

Add this to your bashrc file.

alias ifconfig='/sbin/ifconfig'

Save the file.

source ~/.bashrc

ifconfig
Sean
  • 171
  • 1
  • 2
1

In Ubuntu Server 20.04 you have to install it:

sudo apt install net-tools
Oscar Acevedo
  • 1,144
  • 1
  • 12
  • 19
0

If you are not able to (or do not intend to) connect the virtual machine to the Internet (offline installation), then it would be best to add a CD/DVD drive to the SCSI controller, and mount the CentOS ISO file to this drive. Then, inside the virtual machine, perform the following command:

mount /dev/cdrom /mnt

You can access packages from the ISO via:

cd /mnt/Packages
find . -name "net-tools"

You should have at least one result returning <net-tools-filename>.rpm, for example, net-tools-2.0-0.22.20131004git.el7.x86_64.rpm. Install using that rpm file:

yum install <net-tools-filename>.rpm

Type y when prompted "Is this okay [y/d/N]:" and submit. Once installation is complete, you should be all right when prompting for the ifconfig command again.

Zac
  • 149
  • 1
  • 2
  • 12
0

Install nothing...

Just type sudo before ifconfig

for ex- sudo ifconfig

0

If you install net-tools and the ifconfig is dispay as not found YOU CAN Creating aliases WHICH is relatively easy and quick process.

In order to do that you can use the following command:

alias ifconfig=/sbin/ifconfig

But this is not permanent is just temporary. In order to make it permanent use the following command:

sudo nano ~/.bashrc

Then you can add here your command at the bottom

#My custom aliases
alias home=”ssh -i ~/.ssh/mykep.pem tecmint@192.168.0.100”

alias ll="ls -alF"
alias ifconfig="/sbin/ifconfig"
Soteris 92
  • 41
  • 3