25

I need to ping Google to see my Internet status. In Windows we use:

ping -t [websitename]

In the run menu. How do I do this on Ubuntu?

  • To see the timeout status, ms, etc. of a particular website –  Sep 12 '15 at 15:20
  • 1
    I generally find it more useful to ping my DNS server (8.8.8.8) to test for internet connectivity than hitting Google or Facebook or whatever. If any given website you ping goes down, you still have access to the rest of the web; if you lose the ability to do DNS lookups, the rest of the web stops working for you too. – Aoeuid Sep 13 '15 at 05:52
  • 4
    The whole internet? (O.o) – zxq9 Sep 13 '15 at 08:59
  • Read man ping, of course. – waltinator Sep 30 '15 at 19:45

4 Answers4

34

As far as I know, on Windows by default ping somesite.net will send 4 ICMP echo request packets to the somesite.net. As you have used the -t option i.e. ping -t somesite.net, this will run indefinitely on Windows i.e. it will keep on sending ICMP echo request packets until you quit it yourself.

On Ubuntu ping soemsite.net will run indefinitely i.e. it is same as ping -t soemsite.net for Windows. On the other hand if you want to send a certain number of packets you can use the -c option. E.g., to send 4 ICMP echo request packets you need to open the Terminal with Ctrl+Alt+T and run:

ping -c 4 somesite.net

Also any packet ping sends is highly configurable on Ubuntu. Check man ping to get more ideas.

heemayl
  • 91,753
  • How do I stop it? Using ping somesite.net on Windows would always only make it ping 10 times or so. I just did that on Ubuntu and like you said it's doing it indefinitely. How do I stop it? I'm worried that if I just exit out it could screw something up. – SarahofGaia Nov 18 '15 at 17:36
  • @SarahofGaia You can specify a certain number of requests to be sent by using -c option e.g. ping -c 10 somesite.net will send 10 packets.... On the other hand, you can terminate an ongoing ping operation by pressing Ctrl + c on the keyboard – heemayl Nov 18 '15 at 17:40
19

Please open a terminal Ctrl+Alt+T. Enter:

ping -c3 www.google.com

If you get ping returns, then you are connected. For example:

--- www.google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 20.697/21.033/21.260/0.294 ms
A.B.
  • 90,397
chili555
  • 60,188
14

chili555's answer already covers the question, however if you're trying to debug a connection issue traceroute is way more verbose (you'll have to enable the Universe repository in order to install it):

sudo apt-get update && sudo apt-get install traceroute

Sample output of traceroute askubuntu.com on my machine:

ubuntu@ubuntu ~ % traceroute askubuntu.com 
traceroute to askubuntu.com (104.16.17.44), 30 hops max, 60 byte packets
 1  192.168.0.1 (192.168.0.1)  2.869 ms  3.661 ms  4.413 ms
 2  * * *
 3  0.0.0.0 (0.0.0.0)  33.405 ms  35.751 ms  37.452 ms
 4  0.0.0.0 (0.0.0.0)  42.541 ms 0.0.0.0 (0.0.0.0)  44.504 ms 0.0.0.0 (0.0.0.0)  50.297 ms
 5  0.0.0.0 (0.0.0.0)  53.278 ms 0.0.0.0 (0.0.0.0)  55.500 ms 0.0.0.0 (0.0.0.0)  57.140 ms
 6  * 0.0.0.0 (0.0.0.0)  32.867 ms  33.419 ms
 7  0.0.0.0 (0.0.0.0)  34.096 ms  35.122 ms  40.241 ms
 8  0.0.0.0 (0.0.0.0)  40.910 ms  41.986 ms  45.287 ms
 9  0.0.0.0 (0.0.0.0)  46.972 ms  47.290 ms  53.258 ms
10  104.16.17.44 (104.16.17.44)  53.822 ms  31.788 ms  33.164 ms
kos
  • 35,891
1

If you merely wish to test if your connection is working, a simple way is to use fping with example.com. fping returns 0 on success; see the manual for details on return codes.

if fping -q example.com
then
    # Connection is working.
else
    # Connection is not working.
fi
Paddy Landau
  • 4,548