Developer Forums relocated!

Need help with Apple Developer tools and technologies? Want to share information with other developers and Apple engineers? Visit Developer Forums at Apple.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

-bash: ping: command not found

Ok ,i have a small problem on a website and i ping it. But when i write on terminal for example:


ping www.google.com


the terminal response is:

ping www.google.com

-bash: ping: command not found

But, if i write

/sbin/ping www.google.com

the terminal response is:

/sbin/ping www.google.com

PING www.google.com (172.217.21.196): 56 data bytes

64 bytes from 172.217.21.196: icmp_seq=0 ttl=51 time=25.086 ms

64 bytes from 172.217.21.196: icmp_seq=1 ttl=51 time=42.283 ms

64 bytes from 172.217.21.196: icmp_seq=2 ttl=51 time=63.917 ms

64 bytes from 172.217.21.196: icmp_seq=3 ttl=51 time=80.465 ms

64 bytes from 172.217.21.196: icmp_seq=4 ttl=51 time=46.699 ms

^C

--- www.google.com ping statistics ---

5 packets transmitted, 5 packets received, 0.0% packet loss

round-trip min/avg/max/stddev = 25.086/51.690/80.465/18.967 ms

I want to use the ping command as everyone and not the command /sbin/ping www.google.com
Does anyone have a solution?

macOS Sierra (10.12.1)

Posted on Nov 12, 2016 9:15 PM

Reply
Question marked as Best reply

Posted on Nov 12, 2016 11:51 PM

I solved the problem by writing these two command lines:

export PATH="/usr/bin:/bin:/usr/sbin:/sbin"export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
8 replies

Jun 18, 2017 6:35 AM in response to banana40

Sounds like you need to adjust your PATH.

See what it currently looks like:

Command:

echo $PATH

Set your path (can look something like this)

Command:

export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Or

Edit - nano ~/.bash_profile


If you use something like homebrew, or zsh or others you actually can have a different source profile.

Command:

echo $0

That will tell you what shell you are using.

Nov 12, 2016 10:21 PM in response to banana40

Hello again banana40,

This is a Terminal configuration issue. On the command-line, everyone's configuration is different. Any instructions I might provide would have to be tailored to your specific configuration. /sbin is already in the default path setting, so if you are lacking that, then you or some 3rd party software has removed it. I can't tell you how to correct that error because I don't how how it was broken.


I suggest creating a new user account in System Preferences > Users & Groups and exploring the default Terminal configuration and environment in that new account. Does ping work there? Compare the settings to your broken account try to find out what went wrong.


My suspicion is that you may have entered some command-line instructions you found on the internet but didn't understand. Therefore I am reluctant to give you any additional instructions that could only cause more damage. You may have also tried to install some ports package like homebrew, Fink, or MacPorts. Those packages make it quick and easy to install software when you don't understand what you are doing. While I don't actively troll against those programs anymore, my low opinion of them has not changed.

Nov 12, 2016 10:41 PM in response to banana40

Yes. You can create a new account and copy the appropriate shell configuration files from the new account to the original account. You have to make sure to copy while logged into the new account to have the correct permissions. Also make sure to have several Terminal windows open. It is common when attempting repairs like this to scramble your login settings. If you try to create a new Terminal window and you don't get a prompt, you will have to use one of your existing, already open Terminal windows to correct it.


Again, I can't tell you exactly what shell configuration files you need to copy. There are defaults, but you are already not using those, so everything is just a guess. You can try the following files:

.profile

.zshrc

.bashrc

.bash_profile


Maybe one of those will do the trick.

-bash: ping: command not found

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.