In this guide, check out how to clear the terminal on Ubuntu.
By default, Ubuntu uses GNOME Terminal as the default terminal emulator. It’s a part of the GNOME desktop. Besides the default one, you should check out the best terminal emulators for Linux.
Launch “Terminal.”
What would the terminal window look like with tons of unnecessary outputs? It’s very simple to generate one using the “yes” command.
Don’t forget to press “Ctrl + C” to stop the output. Otherwise, it will continue printing.
Now that we got all that unnecessary texts, time to clean it up. The simplest way is to use the “clear” command.
This is the standard method of clearing the terminal window. There are definitely other methods. However, it may vary based on the terminal emulator you’re using. For example, if you’re using Putty, then running the clear command will clear just for a single page.
Instead of typing the command, we can also send the clear command to the terminal emulator using “Ctrl + L.” Some terminal emulators may have a different keyboard shortcut, for example, “Ctrl + Shift + K.”
The clear command will clear the terminal screen of the outputs. It’s possible to re-initialize the terminal. It will remove all the temporary command history and reload all the terminal configurations. Note that it may also remove any temporary changes to environment variables.
To reset the terminal, run the reset command.
It may take a few moments to re-initialize the terminal. The reset command is recommended to use only when it’s necessary. Otherwise, the clear command is the safe option.
There’s another more complicated way of doing so. We can set an alias to send a reset command to the terminal. Learn more about bash aliases. Unlike the reset command, however, this one does so a bit differently.
Here, cls will be the alias for the command printf “33c”. The alias is declared in the “~/.bashrc” file.
Reload bashrc to take the changes into effect.
The command is telling the print function to print the character 033. It’s an octal number, leading with zero, ending with a ‘c.’ According to ASCII encoding, it’s the value for the ESC (escape) character.
In the terminal control sequence (specifically VT100 control sequence reference), “c” is the command to reset all terminal settings to default.
Run the alias we just set.
This is one of the essential things to learn when working with the terminal. If you ever worked with terminal, then you already know it. However, it doesn’t hurt to refresh the elementary topics.
Whatever terminal emulator you’re using, it interfaces with the shell to execute the commands. Bash is the most common shell on Linux. It’s a shell that also supports scripting. Bash scripting is a programming language on its own. Many Linux programs use bash scripts to deliver their functionalities. Here’s a quick starter guide on bash scripting.
Happy computing!
Here’s the guide to deploy Elastic Stack on Ubuntu VPS, with secure access, HTTPS proxying,…
This guide walks through deploying Nagios Core on an Ubuntu VPS, from system prep to…
After a decade under Pablo Cantero's stewardship, Shoryuken has a new maintainer - me. I'm…
MAAS 3.7 has been officially released and it includes a bunch of cool new features.…
Update: This article originally concluded that Eisel-Lemire wasn't worth it for Ruby. I was wrong.…
Recently, the team at MinIO moved the open source project into maintenance mode and will…