How to completely empty the terminal screen in a Linux system

Source: Internet
Author: User
Tags clear screen

Linux users, especially Ubuntu or CentOS users, are generally accustomed to using the clear command or the Ctrl+l combination shortcut to clear the terminal screen. However, this is not really a clear screen, it just gives the illusion that people think the screen is empty. But when you scroll up with the mouse, you can still see the output left by the previous command operation. When dealing with a large amount of text, this situation can cause us trouble. There are many other ways to clear the screen on the web, but it is basically a variant of the clear command. So, how can you really empty the screen? Share my method below, also can go to e Mentor Network Learning Linux Video tutorial .

Recently found a command that can solve our problem completely.

printf "\033c" is exactly the order we need. It's really empty the terminal screen, and its functionality is similar to the CLS effect provided by CMD.EXE in DOS.

But what exactly does this command do? How does it work?

\033 = = \X1B = = = ESC

As a result, this command becomes C, which is the escape code for "full Reset (RIS)" in Vt-xxx. All of the terminals we use today are VT-compatible, but if you find yourself using a very strange terminal, you may not be able to use this command. printf is a built-in command in bash, with the priority of built-in commands being higher than other executable files.

We can also use another command, reset, which also clears the terminal screen, but we can still use the up and down keys to view the history commands. One drawback of this command is that it performs somewhat slowly, perhaps because it does not send the ESC C instruction, but the compatibility of this command is obviously better than the previous one.

The reset command is useful when your terminal controls the disorder. Have you ever encountered a situation where the input characters do not show up at the cursor position? When you hit the ENTER key, the new prompt does not appear on the new line, but instead appears in front of the old prompt. The reset command is to fix the problem. You can also use this command on Cygwin.

Is this method of command useful to you? To learn more about Linux, please pay attention to e-mentor Network Oh!

How to completely empty the terminal screen in a Linux system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.