Windows & Regions

GNU Screen & Linux Job Control

Chapter 4 · Windows & Split Regions Inside a Session

So far every session has held a single shell. A session can hold many, each in its own window, and you can split your terminal to see several windows at once. This is screen's "multiplexing" side (Chapter 1): one SSH connection, many things going on.

Screen's words
A session is the whole thing you attach to. A window is one shell or program inside it. A region is a part of your terminal display that shows one window. Splitting the display makes regions; it doesn't create windows.

Creating and Moving Between Windows

KeysWhat it does
Ctrl-a cCreate a new window with a shell and switch to it
Ctrl-a n / Ctrl-a pNext / previous window
Ctrl-a 0–9Jump straight to window 0–9
Ctrl-a Ctrl-aToggle back to the window you were in before
Ctrl-a 'Prompt for a window number or name to switch to
Ctrl-a "Show a list of all windows to pick from
Ctrl-a wBriefly show the window list on the message line

Windows are numbered from 0. When you close one, its number becomes free and a new window may reuse it, so the numbers can end up with gaps.

Naming and Closing Windows

Window numbers are hard to remember. Ctrl-a A lets you type a title for the current window, which then appears in the Ctrl-a " list and can be used with Ctrl-a '. To close a window, exit its shell, or press Ctrl-a k and confirm. When the last window closes, the session ends (Chapter 2).

Opening a Window From the Command Line

Typing screen inside a session doesn't start a second, nested session: screen notices it's already running and opens a new window in the current session instead. That gives a quick way to open a window that runs a particular command, with a title:

# Inside a session: new window titled "logs" running tail screen -t logs tail -f /var/log/syslog # Inside a session: new window titled "top" screen -t top top

A window started this way closes when its command ends. Chapter 8 shows how to do the same thing from outside the session.

Splitting the Display Into Regions

KeysWhat it does
Ctrl-a SSplit the current region horizontally (one above the other)
Ctrl-a |Split the current region vertically (side by side)
Ctrl-a TabMove the input focus to the next region
Ctrl-a XRemove the current region
Ctrl-a QRemove every region except the current one
# After Ctrl-a S, then Ctrl-a | in the lower region ┌──────────────────────────────────────────┐ │ window 0: vim config.yaml │ │ │ ├────────────────────┬─────────────────────┤ │ window 1: tail -f │ (empty region) │ │ │ │ └────────────────────┴─────────────────────┘
A new region starts empty
A fresh split shows nothing until you put a window in it. Move to the new region with Ctrl-a Tab, then either create a window there with Ctrl-a c or show an existing one with Ctrl-a n, Ctrl-a ", or a number.
Splits are usually lost when you detach
Regions belong to your display, not the session, so after you detach and reattach you normally get a single region again. The windows themselves, and everything running in them, are untouched. Screen's layout commands can save and restore an arrangement, if you want your splits back.

Watching Windows for Activity

When you have several windows, you don't want to keep flicking between them to see whether something happened. Screen can watch them for you:

  • Ctrl-a M — monitor the current window for activity: you'll get a message when new output appears there while you're elsewhere.
  • Ctrl-a _ — monitor for silence: you'll get a message when the window stops producing output for a while, useful to know a long job has finished or hung.

Hands-On Exercises

Exercise 1

In one session, create three windows titled edit, logs and shell. Practise switching between them with Ctrl-a n, a number, Ctrl-a " and Ctrl-a '. Then close logs and open a new window: what number does it get, and why?

📄 View solution
Exercise 2

Build the layout in this chapter's diagram: an editor across the top, tail -f on a log bottom-left, and top bottom-right. Then detach, reattach, and describe what you see.

📄 View solution
Exercise 3

In one window, run sleep 30; echo done and turn on silence monitoring. Switch to another window and wait. What happens, and why might this be more useful than activity monitoring for a long-running job?

📄 View solution

Chapter 4 Quick Reference

  • A session holds windows; the display is divided into regions, each showing one window
  • Ctrl-a c new window; n/p next/previous; 0–9 jump; Ctrl-a toggle; ' prompt; " list; w quick list
  • Ctrl-a A names a window; Ctrl-a k kills it
  • Inside a session, screen -t title command opens a new window instead of a nested session
  • Ctrl-a S horizontal split, | vertical split, Tab next region, X remove region, Q keep only current
  • New regions start empty; splits are usually lost on reattach (use layout to keep them)
  • Ctrl-a M monitors for activity, Ctrl-a _ for silence