Screen managers and terminal multiplexers

Lars Jönsson 2025-06-16

How to use screen managers.

Overview

To be able to run multiple jobs in the same terminal window, Linux provides a couple of utilities. One is screen, but nowadays tmux is preferred as it has more features. Both have the feature to detach from the terminal and later re-attach to it. It is very useful for long unattended jobs.

This guide focuses on the tmux untility.

Usage

tmux sessions

Create a tmux session.

tmux

Detach from the session by pressing Ctrl-b d.

Attach to the session.

NOTE The sub command attach is an abbreviation of attach-session. All sub commands can be abbreviated as long as they are unique.

tmux attach

Exit the session.

exit

If multiple sessions are created, they can be listed by using the list-sessions sub command.

tmux list-sessions

Connect to a specific session. In this case session 0.

tmux attach -t 0

The session can be renamed, e.g. the session 0 can be renamed to backup.

tmux rename-session -t0 backup

Using tmux panes

Within a tmux session, multiple panes can be created. Each pane is a window with its own shell.

tmux has support for using a mouse, but it has to be enabled. Either it can be set for the current tmux session, using Ctrl-b : setw -g mouse on or it can be set globally for all sessions in the configuration file.

Add the following to the ~/.tmux.conf file.

set -g mouse on

The mouse can be used for many of the following commands, but sometimes it is easier to use the keyboard.

Create panes

  • Ctrl-b %: Split current pane into two, top and bottom
  • Ctrl-b ": Split current pane into two, left and right

Navigate between panes

  • Ctrl-b <arrow>: Navigate bewteen panes
  • Ctrl.b q: Briefly display pane indexes
  • Ctrl.b q <num>: Select pane by index

Pane usage

  • Ctrl-b z: Toggle zoom state of the current pane

Arrange and resize panes

  • Ctrl-b M-<1..7>: Arrange panes in one of the seven preset layouts
  • Ctrl-b Ctrl-<arrow>: Resize the current pane in steps of one cell
  • Ctrl-b M-<arrow>: Resize the current pane in steps of five cells