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
10,143
Reaction score
8,714
Credits
83,882
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.
 


OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
10,143
Reaction score
8,714
Credits
83,882
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.
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
10,143
Reaction score
8,714
Credits
83,882
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.
 

Terminal Velocity

Well-Known Member
Joined
Oct 13, 2021
Messages
387
Reaction score
293
Credits
2,786
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
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
10,143
Reaction score
8,714
Credits
83,882
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...
 

dos2unix

Well-Known Member
Joined
May 3, 2019
Messages
1,916
Reaction score
1,515
Credits
13,184
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.
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
10,143
Reaction score
8,714
Credits
83,882
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.
 

sphen

Well-Known Member
Joined
Dec 12, 2022
Messages
868
Reaction score
750
Credits
10,394
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.
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
10,143
Reaction score
8,714
Credits
83,882
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.
 

osprey

Well-Known Member
Joined
Apr 15, 2022
Messages
919
Reaction score
862
Credits
8,724
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