Ping for 4 times

Solution 1:

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.

Solution 2:

Yes, you can. You need to use -c option to tell the ping to do this, like

ping -c 4 google.com

The -c option tells ping program to stop after sending (or receiving ) specified number of ECHO_RESPONSE packets.

See the ping manual page for details.