Frequently Asked Question

What happens when I press Ctrl+C, Ctrl+Z, or Ctrl+D?

Ctrl+C tells the terminal to send SIGINT (signal 2) to the foreground process. The default action on SIGINT is to terminate, so most programs stop. A well-written program can catch SIGINT and clean up before exiting, for example, wget finishes writing the current partial file. SIGINT is a polite request to stop, not a forced kill; the brute-force equivalent is kill -9 (SIGKILL), which the kernel delivers without the process getting a chance to respond.

Ctrl+Z sends SIGTSTP, which suspends the foreground process and gives you the prompt back; resume it with fg or bg. Ctrl+D is different, it isn't a signal at all. It sends end-of-file (EOF) on the terminal. If a program is reading standard input, it sees EOF and usually exits; that's why pressing Ctrl+D at an empty bash prompt logs you out (bash reads EOF on its stdin and stops). Inside a program that takes typed input, cat with no arguments, or a Python REPL, Ctrl+D ends the input.

Further reading and video