Which command is used to clear the screen or terminal in Linux Ubuntu? Learn how to clear terminal in Ubuntu and clear screen in Linux/Unix putty. Linux command for clear screen.
Linux Command To Clear Terminal Screen
To clear terminal screen in Linux Ubuntu, the simplest command is “clear” to clear terminal screen:
clear
The clear command doesn’t need any option with itself. Note that in other terminal emulators or UNIX putty, the clear command may just clear the screen for one page and when you scroll, you can still see the old screen and its outputs.
To prevent clearing the scrollback buffer, one can use the clear command with -x option:
clear -x
You can also use the reset command tp clear the terminal screen. The reset command reinitializes the terminal. The reset command is useful when the terminal doesn’t terminate easily.
The keyboard shortcut to clear the screen terminal is Ctrl+L in Linux. The shortcut works in most terminal emulators. Note that Ctrl+L clears the output and moves the screen one page down. But one can still see the command output history by scrolling up.
Linux Command To Clear Terminal History
To clear the history, type the following command:history -c && history -w
ORrm ~/.bash_history
Clear Bash Shell Terminal History on Logout
You can modify the above command to clear the history when you logout:
echo 'history -c' >> ~/.bash_logout
The Terminal history is stored in a file called “.bash_history” located in the home directory.