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

Is there a keyboard shortcut to delete the current command?

Let's say I have:

$ cp /home/one/two/tree/ /var/www/one/two/three

I want to easily the current command, specially when it's long and I had a typo. The up and down history selection doesn't remove the current command at all.

share|improve this question
What shell (Bash/ksh/zsh) are you using? – zero2cx Sep 8 '12 at 5:59
up vote 6 down vote accepted

Assuming your shell is bash, this question has been asked and answered on SO.

Press Ctrl-U to delete the command line from the location of the cursor up to the beginning. Precede this by Ctrl-E if the cursor isn't at the end of the line.

Or press Ctrl-C to cancel the current prompt and obtain a new one, which has the benefit that you still see the command you typed.

As bash is highly customizable, the above should work in a default setup, but you or your package provider might always reconfigure the shell for a different set of shortcuts.

share|improve this answer
thanks so much! – Michelle Sep 8 '12 at 8:50

Try Command Line Editing?

If you are using Bash, check:

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.