Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
The best answers are voted up and rise to the top
Usually I use ping to check my internet connection. In windows, if I use:
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?
192k5252 gold badges468468 silver badges719719 bronze badges
asked Oct 14, 2012 at 14:06
3,17277 gold badges3232 silver badges4545 bronze badges
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.
answered Oct 14, 2012 at 14:20
6,57911 gold badge2626 silver badges2828 bronze badges
Yes, you can. You need to use
-c option to tell the ping to do this, like
ping -c 4 google.com
-c option tells ping program to stop after sending (or receiving ) specified number of
See the ping manual page for details.
answered Oct 14, 2012 at 14:07
75.4k3131 gold badges191191 silver badges308308 bronze badges
When you want to ping with IP, type:
ping -c 4 192.168.1.100
(remember to put a space between your number
-c 4 and the IP address!
Some will think:
ping 192.168.1.100 -c 4 (WRONG)
answered Sep 29, 2015 at 19:36
ping --helpand 2. Its manual page: