Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 am looking for a way to delete the currently entered command line without wasting seconds on the Backspace key.

For example I scrolled the bash history and have a long command line that would execute when I pressed Enter:

~$ aptitude search openssl | grep dev

But now I decide that I do not want to execute this command. Can I get an empty prompt fast without deleting the whole line with Backspace? On the Windows cmd you can just press Escape and it is gone. This behavior would be what I want.

share|improve this question
up vote 6 down vote accepted

Pressing Ctrl+U will empty the current line.

It's the default kill character on most terminals and it erases the current line (from the cursor to its beginning). The stty command can be used to get or set its value.

[dave@hal9000 ~]$ stty -a
speed 38400 baud; rows 23; columns 75; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?;
eol2 = M-^?; swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
[dave@hal9000 ~]$ stty kill ^T # Set it to Ctrl-T

Be the way, werase stands for word erase, so Ctrl+W erases the word on the left of the cursor.

share|improve this answer
Thanks, that did it. Ctrl-u deletes all characters before the cursor position. – vobject Sep 28 '10 at 10:38
+1: That's been driving me nuts :) – Mike Fitzpatrick Sep 28 '10 at 10:43
@vobject: If your cursor is within the line, Ctrl-u then Ctrl-k (or vice-versa) will get it all. – Dennis Williamson Sep 28 '10 at 16:55

Press Ctrl+C to cancel the command you're entering and go back to a bare prompt.

This is a common key in unix text mode applications:

  • in non-interactive programs, Ctrl+C usually stops the program altogether and goes back to a shell prompt;
  • in interactive programs that execute one command at a time (such as shells), Ctrl+C usually returns to the main command prompt.
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.