Learn › Linux Foundations › Job Control
signals - a hands-on Linux lab on a real virtual machine.
The four control-key combinations that talk to the foreground program: Ctrl-C sends SIGINT (interrupt), Ctrl-Z sends SIGTSTP (suspend), Ctrl-backslash sends SIGQUIT (force quit and core dump), and Ctrl-D sends EOF (end of input, which logs you out at an empty prompt). These are keystrokes, not typed commands, so the drills teach them from a key-to-signal table and prove them with stty -a; job numbers and PIDs vary.
You start a program in the terminal. It hangs. Or it floods the screen. Or it just will not give you your prompt back. Your hand already knows the answer, even if your head does not yet: you press Ctrl and the letter C. The program stops, and the prompt returns.
That reflex is not magic. It is one of exactly four control-key combinations the terminal reserves for talking directly to whatever program is running in front of you. Each one delivers a different message. This lesson names all four, shows you the mark each one leaves on the screen, and gives you the mental model behind them so you never again mash keys and hope. The tool is your keyboard, and the messages are called signals.
The black boxes in this lesson are a practice terminal: a safe sandbox that checks the one command each step teaches. One honest catch, unique to this lesson: the four things you are learning (Ctrl-C, Ctrl-Z, and the rest) are keys you PRESS, not words you type. So they can never be a typed answer the sandbox grades. You will learn those from the tables and the example frames. The command you actually TYPE and get graded on is stty -a, the one that PROVES which key is wired to which signal on any machine.
A signal is a short message the system delivers to a running program. Not text, not a file, just a one-word nudge that means something specific: stop, pause, quit, wake up. The program can be written to react to each nudge however it likes.
Here is the piece most people miss. When you press Ctrl-C, YOU are not talking to the program. You are talking to the terminal, and the terminal turns that keystroke into a signal and delivers it for you. The keyboard is the doorbell; the signal is the message; the terminal is the messenger that carries it to the door.
Every signal has a name, and the names look like shouting: SIGINT, SIGTSTP, SIGQUIT. The SIG prefix just means signal. There is a whole family of them, and a later lesson on kill sends any signal you name by hand. This lesson is only about the four you can send with the keyboard alone, to the one program running in the foreground right now.
The one your hand already knows. Ctrl-C sends the signal SIGINT, short for interrupt. It means: stop what you are doing. Most programs, when handed SIGINT, tidy up and exit. That is why Ctrl-C gets you out of a command that is running long or flooding the screen.
There is a gentler version too. Press Ctrl-C at an empty shell prompt, with nothing running, and there is nothing to interrupt, so bash simply throws away whatever half-typed line you had and gives you a clean new prompt. That is a real, everyday use: you started typing a long command, changed your mind, and want a fresh line without erasing character by character. Press Ctrl-C and start over.
You cannot type Ctrl-C as an answer, but you CAN prove it is the interrupt key. Every terminal keeps a table of which key sends which signal, and stty -a prints it. Run it and read the table:
stty -a
prompt: student@linuxcamp:~$ answer: stty -a output: speed 38400 baud; rows 24; columns 80; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; hint: Type stty, a space, then a dash and the letter a: stty -a
There it is, in the machine's own words. Read the second line: intr = ^C says the interrupt key is ^C, which is how a terminal writes Ctrl-C. Right next to it, quit = ^\ and eof = ^D, and on the next line susp = ^Z. Those four entries ARE the four keys this lesson teaches, and stty -a is you asking the terminal to confirm them. Your baud, rows, and columns may read differently, but intr = ^C and susp = ^Z are the same on essentially every Linux machine.
Ctrl-C ends a program. Sometimes you do not want it dead, you want it PAUSED so you can do something else and come back. That is Ctrl-Z. It sends SIGTSTP, the terminal stop signal, and it freezes the foreground program in place. The program is not gone; it is suspended, sitting still, using no CPU, waiting for you.
When you press it, the shell prints one line to tell you what it did. Picture running a slow sleep 500 and pressing Ctrl-Z:
prompt: student@linuxcamp:~$ answer: stty -a output: ^Z [1]+ Stopped sleep 500 hint: You cannot type Ctrl-Z here, so the graded command stays stty -a. Read the frame above it: pressing Ctrl-Z is what prints the Stopped line.
That [1]+ Stopped line is the mark Ctrl-Z leaves, shown here as an example to read, not to type (the sandbox still grades the typed stty -a). The [1] is the job number the shell gave the paused program, and it will differ on your machine depending on how many jobs you already have. What stays constant is the word Stopped and the command name to its right. From the jobs lesson (Lesson 90): a stopped job is resumed with fg to bring it back to the foreground, or bg to let it keep running in the background.
So Ctrl-C and Ctrl-Z are a pair, and the difference is everything. Ctrl-C says stop and go away, and the program usually exits. Ctrl-Z says freeze right there, and the program waits, suspended, until you call it back with fg or bg. One ends the work; the other parks it. Reach for Ctrl-Z when you need your prompt back for a moment but you are not finished with the program.
Sometimes Ctrl-C does nothing. A program is allowed to CATCH SIGINT and ignore it, or handle it slowly. When Ctrl-C will not budge a stubborn program, there is a heavier hammer: Ctrl-\ (Ctrl and the backslash key).
Ctrl-\ sends SIGQUIT, the quit signal. It is like SIGINT but blunter, and by default it does one extra thing: it tells the program to dump a core on its way out. A core dump is a snapshot of the program's memory at the moment it died, written to disk so a developer can inspect what went wrong. For you as an operator, the point is simpler: Ctrl-\ is the stronger stop when the polite one is being ignored.
It, too, leaves a distinctive mark. Picture pressing Ctrl-\ on that same stubborn program:
prompt: student@linuxcamp:~$ answer: stty -a output: ^\Quit (core dumped) hint: You cannot type Ctrl-backslash here, so the graded command stays stty -a. Read the frame: pressing Ctrl-backslash is what prints Quit (core dumped).
Quit (core dumped) is the fingerprint of Ctrl-\, shown as an example to read rather than type. On many desktop and server setups the core file is size-limited to zero, so you see the Quit message but no file actually lands, and that is normal. The one thing to remember: if Ctrl-C is ignored, Ctrl-\ is your next, firmer try before you go hunting for kill.
The fourth key is the odd one out, and confusing it with the others is the classic beginner trap. Ctrl-D is NOT a signal. It sends EOF, which stands for end of file, or more usefully here, end of input. It means: I am done typing, there is no more input coming.
That makes Ctrl-D behave in two very different ways depending on where you press it. When a program is reading what you type (say you ran cat with no file and it is waiting for lines), Ctrl-D on its own line tells that program the input is finished. The program then wraps up cleanly. But press Ctrl-D at an EMPTY shell prompt, with no program reading input, and you are telling the SHELL itself that its input is done. The shell takes you at your word and exits. If that was your only terminal window, it closes.
This is the gotcha that catches everyone once. Ctrl-D at an empty prompt logs you out or closes the terminal, because you just told the shell there is no more input. If you only meant to cancel a half-typed line, that is Ctrl-C's job, not Ctrl-D's. And Ctrl-D only signals end-of-input when the line is empty: press it mid-line and most shells ignore it or use it for tab-style completion instead, so nothing dramatic happens.
This is the table to burn into memory. Four keys, four different messages, four different marks on the screen:
Three of these are signals the terminal delivers for you. The fourth, Ctrl-D, is end-of-input, which is why it exits a shell instead of interrupting a program. Keep that one in its own box in your head.
A quick way to remember the pair that matters most: C for Cancel (Ctrl-C stops the program) and Z for Zzz (Ctrl-Z puts it to sleep). Cancel ends it; sleep parks it until fg wakes it up.
Scaffolding off. No command is printed this time. You have every piece you need.
You are on an unfamiliar machine and a colleague swears the suspend key is not Ctrl-Z on it. You do not guess and you do not test it on a live program. You ask the terminal itself to print its full key-to-signal table, so you can read the susp and intr entries with your own eyes. Type the one command from this lesson that prints that table.
prompt: student@linuxcamp:~$ answer: stty -a output: speed 38400 baud; rows 24; columns 80; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; hint: It is the same command that printed the table earlier: stty, a space, dash a.
That is the move. stty -a prints every control-key binding the terminal knows, and reading intr = ^C and susp = ^Z settles any argument about which key sends which signal, no guessing and no risky test on a real program. Your baud and window size will read differently, but those signal bindings are what you came to confirm. You recalled the command from its purpose alone, which is exactly the recall the real machine will ask of you.
Two situations are worth recognising on sight, because the fix for each is different.
Ctrl-C does nothing. You press it and the program keeps running. This is not broken; a program is allowed to catch SIGINT and decide to ignore it or handle it slowly. What to try first: press Ctrl-\ instead, which sends the blunter SIGQUIT. If even that fails, the program is deliberately ignoring keyboard signals, and your next lesson, kill, sends a signal it cannot refuse.
Ctrl-D closed my terminal. You meant to cancel a line and the whole window vanished. That is Ctrl-D doing its real job: at an empty prompt it signals end-of-input and the shell exits. What to check first: was the line empty? If so, that is expected. To cancel a half-typed line without exiting, use Ctrl-C, which clears the line and hands you a fresh prompt.
You earned this cheat sheet. The top rows are keys you press; the bottom row is the one command you type to prove them:
The mental model to keep: your keyboard sends messages called signals, the terminal delivers them to the one foreground program, and each key carries a different message. Ctrl-C stops, Ctrl-Z parks, Ctrl-\ forces the issue, and Ctrl-D says the input is done.
Everything here acts on the ONE program in the foreground. To signal a background program, or one that is ignoring the keyboard entirely, you name it and signal it by hand with kill, coming up in this module.
The practice terminal has shown you the four keyboard signals and the one command that proves them. You typed stty -a yourself and read the terminal's own binding table, and you recalled that command from its purpose in the challenge. The four keystrokes you now carry in the table: Ctrl-C to interrupt, Ctrl-Z to suspend, Ctrl-\ to force a quit, and Ctrl-D for end-of-input.
The Job Control module ends with one real Linux machine, the Job Control capstone mission, and that is where you press these keys for real, against programs that actually run, pause, and resume while you work. A VM boots just for you. It hands you objectives that use exactly what you practiced across this module: starting jobs, pausing and resuming them, moving them between foreground and background, and stopping them with the right key. One difference from here: the mission shows no commands. You read the objective, you recall the move, you make it. That recall is what makes it stick.
Finish the other Job Control lessons, then go drive a real machine's running programs with your keyboard.
Practice Keyboard Signals in a real Linux terminal at The Linux Camp. Progress is verified automatically as you type commands on the machine.