You can stop or terminate a running command in the Linux terminal by pressing CTRL + C
. This is known as the "interrupt" command, and it is a common way to stop a command that is running in the terminal.
When you press CTRL + C
, the terminal sends an interrupt signal (SIGINT
) to the command, which causes it to terminate. This is often used to stop a command that is running indefinitely or taking a long time to complete.
It's worth noting that not all commands will respond to the CTRL + C
interrupt signal. Some commands may ignore the signal and continue running, while others may have their own methods of handling the signal (e.g., by saving state and exiting cleanly). In these cases, you may need to use a different method to stop or terminate the command.
It's also worth noting that the CTRL + C
interrupt signal is not the same as the "terminate" signal (SIGTERM
), which is used to request that a process terminate gracefully. To send a SIGTERM
signal to a process, you can use the kill
command, followed by the process ID of the process you want to terminate. For example:
kill 12345
This will send a SIGTERM
signal to the process with the process ID 12345
, requesting that it terminate gracefully. If the process does not respond to the SIGTERM
signal, you can use the kill -9
command to send a SIGKILL
signal, which will forcibly terminate the process.
kill -9 12345