Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know there is ctrl+c, but sometimes that doesn't work. In Ubuntu desktop I can just close the terminal window and open a new one when this happens, but how would this be solved using the CLI in Ubuntu server (without restarting the box)?

share|improve this question

migrated from Nov 30 '11 at 21:27

This question came from our site for system and network administrators.

see also How to bind a key to sigkill in bash? – warren Nov 30 '11 at 22:12
up vote 15 down vote accepted

CTRL+C will send SIGINT to the application. The application can configure a handler for this signal or it can ignore the signal. By default there is no handler and SIGINT will kill the application.

You can use CTRL+\ which will send SIGQUIT. This will also generate a core dump if the core limit is not zero.

You can suspend the process and return to shell with CTRL+Z, this will stop the execution of the process and return to the shell prompt. The process will be in memory and it will be available as a job in the current shell. You can then use kill -SIGNAL %% or kill -SIGNAL %<job_ID> to send a signal to that job. E.g. to kill the last job use kill -9 %%

If none of them are working you can always send SIGTERM, then, as last resort, SIGKILL which will terminate any process. This signal as any other signals must be sent as the same user as the process you are trying to stop or as root. To send SIGKILL to process, first find the process with ps aux or ps -edf, then run kill -SIGKILL <process_ID>, where the <process_ID> is the PID column in ps output.

The signals can not be delivered if the process is in an uninterruptible call. Uninterruptible calls are kernel functions that can not be stopped and usually happen because of a bad driver (e.g. a driver that is not reentrant). A process that is in uninterruptible sleep can not be stopped until the call gets completed or the server is rebooted.

If a process becomes a zombie, it will not use any resources only taking space in the process table. A zombie process can not receive signals.

The list of signals for the current architecture can be found with kill -l

See the man pages of kill, ps and bash. To see a man page use something like: man ps

share|improve this answer

If you have full console access, you can do Alt-F1..12 and get a new console.

From there, you can do a process listing like follows:

ps aux | grep <process-name>

Then do a kill on the process ID:

kill -9 <pid>

If you don't have full console access, just open another terminal window (perhaps via PuTTY or similar), and do the above process listing and kill steps.

share|improve this answer

Ctrl C sends a SIGINT to your running process. If you don't want to open another console you can send a SIGQUIT with Ctrl \. This will address most day to day hung apps that the SIGINT does not.

I've personally wanted a way to send a SIGKILL with a shortcut but I'm not aware of a way to do so.

share|improve this answer

I consider pgrep and pkill to be easier to use than kill with an explicit process ID.

Also, instead of starting with signal 9 (SIGKILL), consider starting with the default SIGTERM (15). This will give the process a chance to terminate gracefully (if it can). pkill -15 thing and pkill thing should be equivalent.

Here's how that would work. Let's say that ntpd is hung.

What are the processes? (You can skip to pkill if you believe you won't have false positives).

$ pgrep -fl ntp
1034 /usr/sbin/ntpd
1037 /usr/sbin/ntpd

Kill the processes:

$ pkill ntpd

Use pgrep again to see if it was successful.

If not, eventually move to pkill -9.

share|improve this answer

You would switch to a new terminal, find the PID of the stuck process (using ps), then use kill to kill the process. I would first use kill (PID). If that doesn't work, I would use kill -9 (PID). If that doesn't stop the process the machine needs to be rebooted.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.