reverse engineered

Cygwin Ping

If you use Cygwin, you may notice that when you try to use the ping command, you get an error.

This is because typing ping in a Cygwin terminal window executes the *nix version of ping rather than the Windows ping. The *nix ping requires low level socket access that is only available when running as an Administrator. Because there is no sudo command in Cygwin, the only way to acquire administrator privileges is to quit your current terminal window and restart it with the privileges. This is rather cumbersome if you simply want to check whether a server is running.

The solution is to create an alias to the Windows ping in your .bash_profile file. That means any time you run the ping command, you are now running the windows version which requires no admin rights.

Add the following line to the .bash_profile file (create it if necessary) in your home directory.

alias ping=‘$SYSTEMROOT/system32/ping’


user@host ~
$ ping
ping: socket: Operation not permitted


user@host ~
$ pingw

Pinging [] with 32 bytes of data:
Reply from bytes=32 time=24ms TTL=56
Reply from bytes=32 time=23ms TTL=56
Reply from bytes=32 time=23ms TTL=56
Reply from bytes=32 time=23ms TTL=56

Ping statistics for
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 23ms, Maximum = 24ms, Average = 23ms

If you require the *nix native version of ping at any time, you can simply run /bin/ping with admin rights.

comments powered by Disqus