How to reset terminal in Linux

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
How to reset terminal in Linux
How to reset terminal in Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Methods for how to reset terminal in Linux



  1. The best method to reset your terminal is with the reset command. 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.
    $ reset
    
  2. 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.
    Resetting terminal in GNOME desktop environment
    Resetting terminal in GNOME desktop environment

    Note you will need to press Enter again afterwards to return to a prompt.

  3. Another way to reset the terminal is with the clear command. 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.
    $ clear
    
  4. 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 + C keyboard combination. You could also try Ctrl + Z to background the process tying up your terminal, then kill it manually after you have the prompt back.
  5. 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
    



  6. Keep in mind that you can always exit a terminal session and start a new one in the worst case scenario.
    $ exit
    

Closing Thoughts

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.



Comments and Discussions
Linux Forum