shortcutsguide

Clear the Current Line in Terminal (Ctrl+U)

Press Ctrl+U to wipe the command line from the cursor back to the beginning — the fastest way to start a command over. Same key in bash and zsh on Mac, Linux and WSL.

ActionMacWindows
Delete to start of line Ctrl+U Ctrl+U
Delete to end of line Ctrl+K Ctrl+K
Delete previous word Ctrl+W Ctrl+W
Paste last deletion (yank) Ctrl+Y Ctrl+Y
Delete one character left Ctrl+H Ctrl+H

Wipe the line and start over

Press Ctrl+U to delete everything from the cursor back to the start of the line. If your cursor is at the end (the usual case), that clears the whole command. It works the same in bash and zsh on macOS Terminal, Linux and Windows WSL / Git Bash.

Ctrl+U vs Ctrl+K vs Ctrl+W

Ctrl+U kills to the start of the line, Ctrl+K kills to the end, and Ctrl+W kills just the word before the cursor. All three put the text in the readline kill-ring, so you can paste it back with Ctrl+Y if you deleted too much.

Note for zsh users

In some zsh configurations Ctrl+U kills the whole line rather than only to the cursor. To match bash's behaviour add bindkey "^U" backward-kill-line to your .zshrc.

FAQ

How do I clear the current command line in the terminal?

Press Ctrl+U to delete from the cursor to the start of the line. With the cursor at the end, that clears the entire command.

What is the difference between Ctrl+U and Ctrl+K?

Ctrl+U deletes to the beginning of the line; Ctrl+K deletes to the end. Use Ctrl+U to clear what you typed and start over.

Can I undo Ctrl+U?

Yes — the deleted text goes to the kill-ring. Press Ctrl+Y to yank (paste) it back.

Does Ctrl+U clear the whole line or just to the cursor?

In bash it deletes from the cursor to the start. Some zsh setups clear the whole line; rebind to backward-kill-line to match bash.