Fundamentals 8 min read

Master GNU Screen: Install, Use, and Customize Your Linux Sessions

This tutorial explains how to install GNU Screen on various Linux distributions, start and manage screen sessions, use key bindings for window and pane control, detach and reattach sessions, and customize behavior through a .screenrc file, providing practical commands and examples for reliable remote work.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master GNU Screen: Install, Use, and Customize Your Linux Sessions

Introduction

GNU Screen is a terminal multiplexer that lets you run multiple virtual terminals within a single SSH session, keeping programs alive even after disconnection.

Installation

Most Linux distributions ship Screen by default. Verify installation with: screen --version If missing, install it using the package manager of your distribution:

Ubuntu/Debian: sudo apt install screen CentOS/Fedora:

sudo yum install screen

Starting a Screen Session

Launch a new session by typing: screen The command creates a session with a single window running a shell. Press Ctrl+a ? to list all key bindings.

Naming Sessions

When running multiple sessions, give each a descriptive name:

screen -S session_name

Managing Windows and Panes

Screen starts with one window. Create additional windows, split panes, and navigate using these common bindings: Ctrl+a c – create a new window Ctrl+a " – list all windows Ctrl+a 0 – switch to window 0 Ctrl+a A – rename current window Ctrl+a S – split current region horizontally Ctrl+a | – split current region vertically Ctrl+a Tab – move focus to next region Ctrl+a Ctrl+a – toggle between current and previous region Ctrl+a Q – close all regions except the current one Ctrl+a X – close the current region

Detaching and Re‑attaching

Detach from a session at any time with: Ctrl+a d The programs continue to run in the background. Re‑attach later using: screen -r If multiple sessions exist, list them with screen -ls and re‑attach a specific one by its ID, e.g. screen -r 12475.

Customizing Screen

Screen reads configuration from /etc/screenrc and ~/.screenrc. A typical .screenrc might contain:

# Disable welcome message
startup_message off

# Turn off visual bell
vbell off

# Increase scrollback buffer
defscrollback 10000

# Custom status line
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}]%=%{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?=%{g}][%{B} %m-%d %W %c %g]'

These settings suppress the startup banner, disable the visual bell, enlarge the scrollback buffer, and define a persistent status line showing date, time, and window information.

Basic Workflow

Start a session: screen Run the desired commands or programs.

Detach when you need to disconnect: Ctrl+a d Re‑attach later:

screen -r

Conclusion

By following this guide you can install GNU Screen, create and manage multiple windows, detach and resume sessions, and tailor the environment with a custom .screenrc. These capabilities make remote work on Linux servers more resilient and productive.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Command LineSession Managementterminal multiplexerGNU Screen
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.