4

Sometimes after I accidentally typing something in the terminal, e.g. after invoking a "tee" command I am unable to quit from that program to get back to the terminal. I usually try typing :q, quit, CTRL-Break, but nothing helps. So I close the terminal and open a new instance. Is there a standard way to quit from the executing command?

1
  • Another option is Ctrl+\. Like Ctrl+C, programs can catch the signal generated by Ctrl+\ and keep running if they want to, but very few programs do so. Aug 15, 2014 at 16:06

1 Answer 1

10

You can Use Ctrl + C or can use Ctrl + Z key to terminate a running process in command line

3
  • Thank you. What is the difference b/w CTRL+C and CTRL+Z in that case?
    – Mitten
    Aug 10, 2013 at 8:41
  • 4
    Ctrl+C sends a signal to the the program to exit, while Ctrl+Z suspends the program. The program in question can choose what to do when receiving the signal from Ctrl+C, whereas Ctrl+Z stops it right away. You should only use Ctrl+Z when Ctrl+C doesn't work (since Ctrl+C gives the program the chance to clean up temporary files and so on).
    – evilsoup
    Aug 10, 2013 at 9:27
  • 1
    @evilsoup: As noted in a comment under the answer you linked to, Ctrl+Z also sends a signal (SIGTSTP) that is catchable (although very few programs do so). And, to clarify the above answer, if you type Ctrl+C and get a shell prompt back, you have terminated the running process. If you type Ctrl+Z and get a shell prompt back, you have only suspended the process – it’s still alive, just not running. Aug 15, 2014 at 16:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .