Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. 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:

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?

share|improve this question
1  
Nearly every command (including ping) in Linux comes with extensive manuals: 1. Its help text: ping --help and 2. Its manual page: man ping – jippie Oct 14 '12 at 14:31
up vote 15 down vote accepted

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.

share|improve this answer
    
+1 for the alias. I was thinking about a system wide settings. Yours is a nice solution – Anwar Shah Oct 14 '12 at 14:28

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.

share|improve this answer

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)
share|improve this answer
    
ping 192.168.1.100 -c 4 is NOT wrong. – Pilot6 Feb 4 at 16:36

Just type

ping www.google.com

And you are good to go. This will ping www.google.com infinite times. To stop the ping press Ctrl + Z.

share|improve this answer
    
This is no better than the question. – muru Feb 4 at 14:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.