Using the command line terminal is the most powerful way to administer a Linux system. Sometimes, though, a terminal can get hung up and become unresponsive. The terminal can also bug out if you try to read a binary file, filling your screen with strange characters.
In such cases, it is useful to reset the terminal. There are several ways to do this across all Linux systems. In this tutorial, you will see how to reset the terminal in Linux.
In this tutorial you will learn:
- How to reset terminal in Linux with commands
- How to reset terminal via GUI
- How to clear terminal history and scrollback buffer
- How to exit from a process tying up the terminal
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Methods for how to reset terminal in Linux
- The best method to reset your terminal is with the
resetcommand. This will wipe everything that is currently in the terminal, including the scrollback buffer (in most terminal applications), and should fix issues such as a bugged terminal or one that is displaying strange characters.
- One of the other easiest ways to reset your terminal is from its own menu, assuming that you are using a GUI. On GNOME, the option is located in the menu under Advanced. You can choose to either reset the terminal or to reset AND clear it. These instructions may vary a little bit depending on which desktop environment you are running.
Note you will need to press
Enteragain afterwards to return to a prompt.
- Another way to reset the terminal is with the
clearcommand. This will clear your entire screen and make it seem as if you just opened up a new terminal instance. It may not fix issues such as a bugged out terminal from trying to read a binary file, but it will clear most problems or just hide your terminal history from your screen.
- If a process has taken over your terminal, and you are trying to return to a normal prompt, you can usually exit most processes with a
Ctrl + Ckeyboard combination. You could also try
Ctrl + Zto background the process tying up your terminal, then kill it manually after you have the prompt back.
- In case you need to clear all of your terminal history, so that no one can see what commands you have typed, you could use the following chain of commands. This should work in any terminal, although it is up to the application whether or not it clears the scrollback buffer.
$ cat /dev/null > ~/.bash_history && history -c && reset
- Keep in mind that you can always
exita terminal session and start a new one in the worst case scenario.
In this tutorial, you saw how to reset a command line terminal on a Linux system. We tried to cover every possible scenario here, including a bugged out terminal, one that displays weird characters, clearing the terminal history and scrollback buffer, and exiting from a terminal completely. Remember that your GUI may also contain a way to clear the terminal, as we showd you on GNOME.