How to increase the scrollback buffer in a running screen session on Linux?

Screen (also known as GNU Screen) is a terminal multiplexer that allows you to start a screen session and open multiple windows within that session. Processes running in Screen continue to execute even when their windows are not visible, making it ideal for long-running tasks and remote sessions.

When working with Screen sessions, you may need to increase the scrollback buffer to view more historical output. The scrollback buffer stores previous terminal output that you can scroll back to review.

Installing Linux Screen

If Screen is not already installed on your Linux distribution, use one of the following commands:

For Ubuntu and Debian

sudo apt update
sudo apt install screen

For CentOS and Fedora

sudo yum install screen

Starting Screen

Start a new screen session with:

screen

To list all active screen sessions for the current user:

screen -ls

Increasing Scrollback Buffer in Running Session

Important limitation: You cannot retroactively increase the scrollback buffer to recover old lines that have already been discarded. However, you can change the scrollback setting for future output in the current session.

Method 1: Using Screen Command Mode

To change the scrollback buffer size in a running screen session:

  1. Press Ctrl + A, then press : (colon) to enter command mode

  2. Type the following command and press Enter:

scrollback <num>

Where <num> is the number of lines you want to store in the scrollback buffer (e.g., scrollback 5000).

Method 2: Setting Default Scrollback

To set the default scrollback buffer size for new windows within the current session:

defscrollback <num>

Permanent Configuration

To make scrollback settings permanent, add the following line to your ~/.screenrc file:

defscrollback 10000

This sets the default scrollback buffer to 10,000 lines for all new Screen sessions.

Viewing Scrollback Buffer

To access the scrollback buffer and navigate through previous output:

  • Press Ctrl + A, then [ to enter copy mode

  • Use arrow keys, Page Up/Page Down to navigate

  • Press Esc to exit copy mode

Common Scrollback Values

Buffer Size Use Case Memory Usage
1000 Light usage Low
5000 Moderate development Medium
10000 Heavy debugging/logs Higher
50000+ Log analysis High

Conclusion

While you cannot recover already-discarded lines in a running Screen session, you can increase the scrollback buffer for future output using the scrollback command. For permanent settings, configure defscrollback in your ~/.screenrc file to ensure adequate buffer size for your workflow needs.

Updated on: 2026-03-17T09:01:38+05:30

910 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements