How do I clear the current command line in terminal?


You have type a long line of command in terminal. But now you want to clear or delete the entire line. Deleting each character in the command will take sometime and bored you. So are there any keyboard shortcuts that allow you to do this? Yes there are some hotkeys to the rescue.

Hotkeys Description
CTRL + u Delete the current command.
The deleted command will be stored into a buffer.
CTRL + w Delete a word.
CTRL + c Abort what you are typing.
CTRL + d Delete current character.

Other hotkeys that might help you work faster in the terminal.

Hotkeys Description
CTRL + e Move to the end of line.
CTRL + a Move to the start of line.
CTRL + k Cut text from the cursor to the end of line.
CTRL + y Paste the last cut text or buffer.
CTRL + - Undo.
CTRL + b Backward one character.
CTRL + f Forward one character.
ALT + Backward one word.
ALT + Forward one word.

Wayan Saryada

Founder at Kode Java Org
I am a programmer, a runner, a recreational diver, currently live in the island of Bali, Indonesia. Mostly programming in Java, Spring Framework, Hibernate / JPA. You can support my works by donating here. Thank you 🥳

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.