magna_nz
magna_nz

Reputation: 1273

Can't find ping on macbook

Whenever I go into a terminal and type "ping X" with X being an address, I get

"command not found"

I can't even locate where Ping is, I've looked in /usr/bin and /usr/sbin. I don't even know where it's installed.

$PATH = /Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/local/smlng/bin

Upvotes: 1

Views: 11843

Answers (2)

KaKa
KaKa

Reputation: 559

If the command which ping and echo $PATH give you nothing in terminal, maybe the ~/.bash_profile miss the default paths. Here is the way to check and repair it.

  1. In the terminal, command vim ~/.bash_profile
  2. Check if there has PATH=/usr/bin:/bin:/usr/sbin:/sbin
  3. If not, write it (PATH=/usr/bin:/bin:/usr/sbin:/sbin) in to the .bash_profile file (Steps below will show you how to modify the file)
  4. If it already contains the default paths, then... check another answers

Steps for modify the file with vim:

  1. Type 'a' or 'i' in the keyboard, you will be in the write mode
  2. Now you can modify the file as you wish
  3. Press 'ESC' in the keyboard, you will leave the write mode
  4. Type :wq, you will save the file then quit the vim

Upvotes: 7

AWMoore
AWMoore

Reputation: 251

On a fresh Mac OS X (10.9) install, running the which ping command will yield the following default location:

/sbin/ping

Let's take a look at the default $PATH values for a fresh install of Mac OS X (10.9) using the command echo $PING we see the settings as:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

Now, looking at your $PATH variables, it looks like you are missing the following entries:

  • /usr/sbin
  • /sbin
  • /usr/local/bin

You should be able to fix this by following these steps:

  1. In Terminal, run the following command: sudo nano /etc/paths
  2. Enter your password, when prompted.
  3. Go to the bottom of the file, and enter the missing entries (1 per line).
  4. Hit Control+X to quit.
  5. Enter Y to save the modified buffer.

You should then be able to use ping, ping6, umount, and a number of other commands for programs located in the sbin directories that you weren't able to. If you are still receiving errors, you may need to reboot.

Upvotes: 8

Related Questions