Linux Command: clear and reset (with clear left and right hotkeys)

Use the following command to get a clear terminal screen. The following commands are handy and provide very easy-to-use options and/or shortcuts.

Clear – clean terminal screen

Clear the terminal when it is overloaded with commands or information by using the “clear” command-

clear
Bash

There is a shortcut/hotkey for this-

CTRL + L
Bash

** This does not remove or delete the output from the screen. It just move the outputs above, so that we can see a clean screen.

** You can still scroll up and see the previous output.

Reset – terminal initialization

Use the reset command to clear all the output from the terminal-

reset
Bash

This will remove all output from the terminal. We will not be able to scroll up and see the out.

The terminal will be as fresh as new.

** this will not do anything to the command history, just the output from the terminal will be clean.

CTRL + U – clear everything on the left

Use the following hotkey to clear everything from the left of the cursor-

CTRL + U
Bash

Example:

$ some command here

# Say the curor is at the end
# then press CTRL + U
# The line will be cleard

$
Bash

Another example-

$ Something wrong ls -la

# Say the cursor is before "ls"
# and you press CTRL + U
# then the text before "ls" will be deleted
# and you will get result as below

$ ls -la
Bash

CTRL + K – clear everything on the right

Use the following hotkey to clear everything from the right of the cursor-

CTRL + K
Bash

Example:

$ ls -la some extra params

# Say the cursor is before "some ...."
# and you press CTRL + K
# then the text from "some...." will be deleted
# and you will get result as below

$ ls -la
Bash

Leave a Comment


The reCAPTCHA verification period has expired. Please reload the page.