100tiao1: How-to instructions you can trust. Linux How to Increase Scrollback Buffer Size of the Terminal Emulators in Linux

How to Increase Scrollback Buffer Size of the Terminal Emulators in Linux

Have you ever found yourself scrolling through your terminal’s history, only to realize that the important information you were looking for is no longer visible? This is because the default scrollback buffer size of many terminal emulators is often limited. By increasing the buffer size, you can easily scroll up and refer to previous commands and their outputs.

In this guide, we’ll learn how to adjust the scrollback buffer size in various terminal emulators.

Content

Adjust Scrollback Through the Terminal Setting

Most terminal emulators provide an option to adjust the scrollback buffer size directly through their settings. This is the most straightforward method to tweak the scrollback buffer size in Linux.

For example, if you are using the GNOME terminal, you can increase the buffer size by going to the Preferences menu. You can open this by clicking the hamburger menu button and choosing the Preferences option.

Next, head over to your profile settings and navigate to the Scrolling tab. From there, you can modify the number of lines that the terminal will keep in its scrollback buffer. Adjust this number according to your needs.

You can also adjust other scrolling-related settings, such as the Scroll on output and Scroll on keystroke options, to fine-tune your scrolling experience.

Click Close to save the changes. That’s it! You have successfully increased the buffer size of the GNOME terminal.

Furthermore, you can also change the buffer size for other popular terminal emulators in a similar manner. For example, to adjust Konsole’s scrollback buffer size, simply right-click anywhere on the terminal and select the Adjust Scrollback option.

Here, you can adjust the scrollback lines setting to your desired value. Konsole also offers an Unlimited scrollback option, which can be useful if you want to keep a record of all your terminal output.

Note: Remember that increasing the scrollback limit uses more RAM. If you have a desktop with enough power, it will not impact your computer’s performance, but not all computers have a lot of memory. Also, make sure you have enough space if you choose the unlimited scrollback option.

Some terminals have different approaches to increasing the scrollback buffer size. For example, if you are using Alacritty, you’ll need to edit its YAML configuration file to increase the buffer size.

Pipe Your Output Into less Command

Another way for you to view and review larger outputs without increasing the scrollback buffer size is to pipe your command output into the less command.

With the less command, you can scroll through long command outputs at your own pace without worrying about losing any data. It allows you to view the output one page at a time, making it simpler to navigate and search all the content.

For example, if you run a command that generates a large amount of output, such as ls -lR, you can pipe the output into less like this:

ls -lR | less

This command allows you to view the output one screen at a time. In addition, you can use the arrow keys to navigate up and down. It’s like having a scrollback buffer but with even more control.

You can even search through the output with / followed by your search term, making it easier to find the exact information you need.

Furthermore, if you want to dump the entire output into your terminal instead of viewing it page by page, you can also use the cat command. For example, replace the less command with the cat in the previously mentioned command:

ls -lR | cat

Search Within Output Using grep

There is an option to find a specific string using the less command. However, if you don’t want to pipe your output to less, you can pipe it to grep along with your target text to locate it in the command output.

The grep command allows you to find specific information within a larger output. Additionally, you can search for patterns within text and filter and extract relevant information from command output.

For example, if you want to filter the output and show only lines that contain the word file, run:

ls -IR | grep file

Moreover, grep has many options that allow you to customize your search, such as ignoring case sensitivity (-i), displaying the line numbers (-n), or searching for multiple patterns at once (-e).

Additionally, you can use grep command with regular expressions to perform more complex searches. For instance, to find all lines starting with a number, execute this command:

grep "^[0-9]" output.txt

This will display all lines from output.txt that start with a number.

Wrapping up

Whether you adjust the settings directly in your terminal emulator or use powerful commands like less and grep, these techniques ensure that no information is ever lost. You can also customize your terminal using various options, or even change your default terminal to any other terminal.

Image credit: Unsplash. All alterations and screenshots by Haroon Javed.


Haroon Javed
Contributor

Haroon is a lifelong tech enthusiast with over five years of experience writing thousands of articles about Linux, programming languages, and more. He loves exploring new technologies and experimenting with them to find innovative ways to use them. Haroon’s work has been featured on various online platforms, including HTG, Baeldung, and LinuxHint.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe

Related Post