Today's article is *really* simple - as you're just terminating a terminal command...

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
11,775
Reaction score
10,337
Credits
97,436
This was prompted by my browsing and having seen the same question posted many times over the years. (It hasn't been posted here lately, which is either nice or odd...)

I actually covered this in a bigger article, but that article seems to have been lost in the shuffle. I'm hoping Google indexes this properly so that people don't 'terminate' running processes by 'closing the terminal'. That's the real goal behind it. Otherwise, I took CTRL + C and turned it into a full article... Yes, yes I did...


That's all the article is about. That one combination of keys. Hopefully it is picked up better.
 


Also, it was awfully tempting to post this in 'getting started'... That's really what it's about, but it's a terminal command, so I'll stuff it in this section of the forum.
 
Very useful

I do wonder how many newer Linux users on this site didn't know about this?

But, it was prompted by seeing the same thread I've seen time and time again about stopping a command in the terminal. I did sneak in some information about 'ping', but it's really about CTRL + C.
 
I use Linux some years now and I didn't knew, I thought the proper way to stop a procedure is to close the terminal and open a new one and I'm not the only one on this
 
I use Linux some years now and I didn't knew, I thought the proper way to stop a procedure is to close the terminal and open a new one and I'm not the only one on this

Excellent! You're exactly the person for whom this article was written. Hopefully it's picked up by Google and ranks well, helping others who don't know. Though, there are probably other pages that tell you how, the keywords I picked should be good. Well, hopefully...
 
I think cntrl-C is by far the most used way. But a few others..

I have had to use cntrl-Z in a few occasions.
If I'm afraid I'll break something, I do a "ps" to get the PID and then do a kill or kill -9 on the PID.
On very rare occasions, the terminal locked up and I had to reboot.
Sometimes I can ssh remotely if the local terminal locks up.

If it's a sysV process, often "stop" will work.
If it's a systemd process, usually "systemctl stop..." will work.
 
I have had to use cntrl-Z in a few occasions.

That just pauses it and puts it into the background. You bring it back to the foreground by typing 'fg' and pressing enter.


I should probably have mentioned that some applications, once you're inside them, have other ways to quit them - such as man pages.
 
The article is good, but I would change the title to "How to Terminate a Running Terminal Command".

I expected something different, like a discussion of "&", "\", ";" etc. I also thought it might be about CTRL-U. I did not expect CTRL-C.
 
Yeah, the title was actually a bit of a pain - and is intentionally a bit vague hoping to get a solid score in the Google rankings.

So many people just close the terminal. That may not actually kill the processes in some instances, so I understand.
 
Cntl+c is the interrupt signal and will stop an on-going process like ping as outlined in the article but cntl+u won't stop ping in a standard xterm, though cntl+s will stop it with cntl+q to restart it. Cntl+u will clear the command line from the cursor point to the beginning of the line, thus killing that. There are other ways of controlling in the terminal shown with stty:
Code:
[flip@flop ~]$ stty -a
speed 38400 baud; rows 37; columns 93; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>;
swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
discard = ^O;
<snip>
 
Last edited:

Members online


Top