Usually I use ping to check my internet connection. In windows, if I use:
ping google.com
I get only 4 information ping, but on Ubuntu, if I use that command, the ping can' stop until I stop it with Ctrl+C. Can I ping only for 4 times then stopped? If I can, can I use it as default?
As Olive Twist already answered,
ping -c 4 google.com
will do it.If you want to make this as a default, one way is to create an alias for ping with:
alias ping='ping -c 4'
Save it to your
~/.bashrc
file to make it permanent or it will last only for the current terminal session.Yes, you can. You need to use
-c
option to tell the ping to do this, likeThe
-c
option tells ping program to stop after sending (or receiving ) specified number ofECHO_RESPONSE
packets.See the ping manual page for details.
When you want to ping with IP, type:
(remember to put a space between your number
-c 4
and the IP address!Some will think: