Glam Prestige Journal

Bright entertainment trends with youth appeal.

When I use the 'Ping' command in a terminal window, how do I terminate the ping? I have pinged my router (192.168.1.1) and the results have displayed in the terminal window, but the program keeps running with no indication as to how to terminate.

I can end the command by closing the command terminal window, but I would rather keep it open so I can compare pings with different addresses.

Ubuntu 14.04 LTS

5 Answers

There are three options:

  • Manually interrupt the ping command using Ctrl+C, as described in @steeldriver's answer.

  • Use ping's "count" option (-c COUNT) to send exactly COUNT pings and then terminate automatically, as described in @bodhi.zazen's answer.

  • Use ping's "deadline" option (-w DEADLINE) to run for exactly DEADLINE seconds and then terminate automatically.


Of course you can combine the three options. If you pass both a "count" and a "deadline" option, ping will terminate as soon as the first event occurs. And Ctrl+C works always anyway.

Here's an example with a "count" of maximal 10 pings and a "deadline" of 5 seconds, but which got terminated manually using Ctrl+C after 3 pings (^C):

$ ping -c 10 -w 5 askubuntu.com
PING askubuntu.com (104.16.110.188) 56(84) bytes of data.
64 bytes from 104.16.110.188: icmp_seq=1 ttl=56 time=54.6 ms
64 bytes from 104.16.110.188: icmp_seq=2 ttl=56 time=52.5 ms
64 bytes from 104.16.110.188: icmp_seq=3 ttl=56 time=54.0 ms
^C
--- askubuntu.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 52.582/53.733/54.611/0.850 ms
1

You can use Ctrl+C to send a SIGINT (interrupt signal) to the ping process - see Unix signals

Either give ping a count with the -c option :

ping -c 4 google.com

Or use the keys Ctrl+C to terminate the command.

You should try Ctrl + C to stop the processus.

1

You can try ctrl + c to send an interrupt signal, it will terminate the program without closing terminal

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy