How to terminate a frozen Linux terminal
Summary
Learn how to terminate unresponsive Linux terminals using our quick troubleshooting steps and signals. Discover Linux signal types, how to send them, and their effects: terminate, core dump, stop, and continue. Includes (kill
, pkill
, killall
, Ctrl+c
, and Ctrl+\
).
Introduction #
When a Linux terminal becomes unresponsive or hangs, you may need to send a signal to terminate it manually. Linux provides several ways to send signals to processes, allowing you to regain control of your system.
Understanding how to send signals in Linux is the key for managing unresponsive terminals. Whether you need to terminate, stop, or continue a process, using signals effectively can help you maintain system stability.
Quick troubleshooting steps #
Before you start sending kill signals, try the steps below to regain control of your terminal. If these steps do not work, proceed to sending signals manually.
Try Enter
#
You may have typed a command but forgotten to press Enter
(RETURN), to execute it. D’uh.
Try Ctrl+j
#
You can try Ctrl+j
to reset some terminal systems.
Try Ctrl+z
#
If your shell supports job control, Ctrl+z
suspends the process and returns you to a shell prompt.
Try Ctrl+c
#
You can try Ctrl+c
or Delete
, which stops a running program.
Try Ctrl+q
#
If Ctrl+s
stopped the output, Ctrl+q
should restore it.
Try Ctrl+d
#
Some programs require an end-of-input character (Ctrl+d
) before continuing. This may log you out.
Signals overview #
The table below summarizes the most commonly used signals, their signal numbers, how to send them, their default action, and a brief description of each.
Signal Name | Signal Number | How to Send | Default Action | Description |
---|---|---|---|---|
SIGHUP | 1 | kill -HUP <PID> | Terminate | Hangup detected, used to reload configurations. |
SIGINT | 2 | Ctrl+c or kill -INT <PID> | Terminate | Interrupt signal, stops a process. |
SIGQUIT | 3 | Ctrl+\ or kill -QUIT <PID> | Core Dump | Similar to SIGINT but creates a core dump. |
SIGKILL | 9 | kill -KILL <PID> | Terminate | Forcefully kills a process without cleanup. |
SIGTERM | 15 | kill -TERM <PID> | Terminate | Gracefully asks a process to terminate. |
SIGSTOP | 19 | kill -STOP <PID> | Stop | Suspends a process. |
SIGCONT | 18 | kill -CONT <PID> | Continue | Resumes a stopped process. |
How to list all signals #
To view all available signals on your system, use the following command:
kill -l
This will display a list of supported signals along with their corresponding numbers:
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL
5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE
9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2
13) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGSTKFLT
17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
...
How to send signals #
You can send signals using
- the
kill
command, - the
pkill
command, or - the
killall
command.
These commands allow you to target specific processes by their process identifier (PID) or by name.
Using the kill
command #
To send a signal to a process using its PID, use:
kill -SIGNAL PID
For example, to send SIGTERM
(terminate) to a process with PID 1234:
kill -TERM 1234
Using the pkill
command #
The pkill
command allows you to send a signal to a process by name:
pkill -SIGNAL process_name
For example, to forcefully kill all instances of firefox
:
pkill -KILL firefox
Using the killall
command #
The killall
command sends a signal to all processes matching a given name:
killall -SIGNAL process_name
For example, to terminate all vim
processes:
killall -TERM vim
Explanation of default actions #
Each signal has a default action when sent to a process. Understanding these actions can help you manage processes effectively.
Terminate #
The process is terminated immediately. This is the default action for signals like SIGTERM
and SIGHUP
.
Core Dump #
The process is terminated, and a core dump file is generated for debugging. This occurs with signals like SIGQUIT
.
Stop #
The process is paused but remains in memory. It can be resumed later. SIGSTOP
is an example of this behavior.
Continue #
The process resumes execution if it was stopped. This occurs when SIGCONT
is sent to a suspended process.
Further readings #
Sources and recommended, further resources on the topic:
License
How to terminate a frozen Linux terminal by Jonas Jared Jacek is licensed under CC BY-SA 4.0.
This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, for noncommercial purposes only. To give credit, provide a link back to the original source, the author, and the license e.g. like this:
<p xmlns:cc="http://creativecommons.org/ns#" xmlns:dct="http://purl.org/dc/terms/"><a property="dct:title" rel="cc:attributionURL" href="https://www.ditig.com/how-to-kill-an-unresponsive-linux-terminal">How to terminate a frozen Linux terminal</a> by <a rel="cc:attributionURL dct:creator" property="cc:attributionName" href="https://www.j15k.com/">Jonas Jared Jacek</a> is licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank" rel="license noopener noreferrer">CC BY-SA 4.0</a>.</p>
For more information see the Ditig legal page.