The command

ping <dest> &

causes ping to go to the background. It still prints output to the terminal, however. Ctrl-C does not stop it, only introduces a new prompt. How to stop it from the terminal?

  • In addition to the answers, there is a way to naturally limit ping's iterations with a count — -c N — where N is a positive number. – l0b0 Mar 15 '19 at 18:07
  • 1
    @l0b0 Yes true, but I faced this particular problem, and it's actually related to any program where we might not know the execution time, or where it might not even be defined. So I mean to ask how to stop the process. – Vineet Mar 15 '19 at 18:20

First enter fg into same terminal that your ping command is running (it brings the process into the foreground), then press Ctrl+c to stop the process.

enter image description here

  • This works. I also realized that fg works if we have multiple background processes, by calling them to the foreground one by one. – Vineet Mar 15 '19 at 14:22
  • Yep, that's how it works, you can use jobs to get a list of process that are running in background. – Ravexina Mar 15 '19 at 14:23
  • How did you make that image loop? – phillipsk Mar 16 '19 at 18:25
  • 3
    @phillipsk It's GIF, that's how GIF works ... – Ravexina Mar 16 '19 at 18:31
  • 1
    @Seth Oh... in that case, I captured the video using "Kazam" then convert it to gif using ffmpeg. – Ravexina Mar 26 '19 at 19:21

If it is your one and only background job you can kill it with kill %1. If not sure you can list all your background jobs with jobs and use kill %<n> where you replace n by the number of your ping job.

  • 4
    Also, I found out that n matches the number that is print out in square brackets when running the command. – Vineet Mar 15 '19 at 14:31

When you send a process to the background, whether by using ctrl-z or by & at the end of the command, you get an output in the following format: [index] process-id. If you send multiple processes to the background, the index will keep incrementing every time.

For example:

$ sleep 100 &
[1] 41608
$ sleep 101 &
[2] 41609
$ sleep 102 &
[3] 41610
$ sleep 103 &
[4] 41611
$ sleep 104 &
[5] 41612
$ sleep 105 &
[6] 41613
$ sleep 106 &
[7] 41614

In order to stop a specific one, you can either use kill <process-id> or use fg <index> followed by ctrl-c

Example using the previous output:

$ kill 41614


$ fg 7
sleep 106

Launch a new tab of terminal, run:

$ pgrep ping

Then kill the pid using kill command:

$ kill 2564
  • I used kill in the same terminal too (though the output made it difficult to use). However, I was wondering what to do if I couldn't go far back up in the terminal to see the process id printed, so pgrep has helped, additionally. – Vineet Mar 15 '19 at 14:24
  • 3
    When you use pgrep to search processes by name, you can also use pkill to kill them by name. No need to type/copy the process id and use kill. – Byte Commander Mar 15 '19 at 14:29
  • This is useful to know, but for this question it's a bit of overkill. :-p – tu-Reinstate Monica-dor duh Mar 18 '19 at 1:45

Slightly different approach towards a continuous ping is to use -c option and enter the number of time you want it to run, that way it will stop itself after the desired count i.e. below ping will stop after 100 pings

ping -c 100 &


When you are root, it's simply killall ping.

  • Thanks for killing my ping session I was running on the same machine -- a coworker – Oscar Apr 1 '19 at 13:25

Just use:

kill -9 %%

and it will kill the current background process you're running.


You can see all the process that you put in background (for current session ) with jobs command After you run this command you will see all the process which are running on the current bash and on the left side of each process you can see some numbers :

[1]-  Running                 sleep 200000 &
[2]+  Running                 sleep 300000 &

You can simply terminate jobs (processes) by using kill -15 n% (n is a number that is in [[] sign )

-15 is for terminating process nicely , if you want to force close the process, just use -9 instead of -15 PS : It is obvious if you run a command with root privilege , you have to run kill -15 n% with sudo

2) You can see all of the process that are running on the system with ps -aux and for seeing ping :

ps -aux | grep ping 

The output is like :

root     2615  0.0  0.0  25828  1052 pts/0    S    02:12   0:00 ping

The second number (2615) is PID or process ID and you can terminate the process with

sudo kill -15 2615

Your Answer

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

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