How To: Terminate A Terminal Command

Today’s article is going to be a very brief article, prompted by a question on one of the Linux support forums about how to terminate a terminal command. The poster got an answer, but it was the additional comments that made me realize how few people know how to properly terminate a terminal command – specifically new users.

So, if you want to learn how to terminate a terminal command, read on!

As I said, this isn’t going to be a very long article. I have actually covered this before in another article – but it kinda deserves its own page/article. It’s not a very long and detailed exercise, but it kind of got lost in the mix and I’m compelled to write this article.

I want to make sure that this information is easily found via search engines because the answers I saw to this question included things like ‘just wait’ or ‘start another terminal, just close that one’. None of those are the ‘right’ answer to the question. None of those are the proper way to terminate a terminal command. 

So, let’s see if I can turn this tiny command into a full article about…

How To Terminate A Terminal Command:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

Let’s use the ‘ping’ command as our tool of choice for this exercise. If you type in the following, you’ll continue pinging my site until you tell it to stop.

Of course, you can limit the number of pings you send. That’s easy enough. If you wanted to ‘ping’ linux-tips.us five times, you’d run this command:

The output of which looks similar to:

pinging this site just five times before stopping.
That’s how you properly limit the number of pings to linux-tips.us. Pretty easy, right!?!

But, you can run the first ‘ping’ command and just tell it to stop running whenever you want. The command to do so is:

CTRL + C

The output of this would look similar to this:

stopping a terminal command with ctrl + c
This stopped the command after five runs – but I personally stopped it with the CTRL + C option.

So, if you want to stop a running terminal command, it’s pretty easy. You just need to press CTRL + C on your keyboard and the process will stop. You will have terminated a terminal command the right way.

Note: You don’t always want to terminate processes. Things like terminating a device that’s in the process of upgrading may lead to an unstable condition. Then, for example, terminating a write operation may result in a loss of data.

Processes like that normally shouldn’t be stopped. In those cases, it’s best to just let the computer finish what it is doing – unless, of course, you do need to stop them because you have reasons to do so (like you started writing to the wrong device).

Closure:

Huh… I managed to kinda turn it into a full article, so there’s that. It really is a simple concept and the shortcut to terminate a terminal process is easy enough to remember. In an ideal world, this article will rank well in the search engines and save new Linux users time and effort. I’m not sure if I should aim for ‘terminate’ or ‘stop’, but this needs to be common knowledge – or more widely known than it seems to be at the present.

Also, just because you closed the terminal where you started the process doesn’t mean the process itself has necessarily ended. So, there’s something else to keep in mind. A process can and will happily keep executing even though you’ve closed the terminal. Linux is like that!

I wasn’t really sure that I could fluff this up into a complete article, but it appears that I’ve kinda pretended to do just that! Well, you’ll have another article in just a couple of days. It’ll probably be more involved than this one! This one is all about that CTRL + C function.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.