How to Use tmux for Terminal Multiplexing on RHEL 7

Every Linux administrator has experienced the frustration of losing a long-running process because an SSH connection dropped. tmux (terminal multiplexer) solves this problem by running your terminal sessions inside a persistent server process that survives disconnections. Beyond persistence, tmux allows you to split a single terminal window into multiple panes, manage many windows within a single session, detach and reattach from any machine, and even share a live session with another user. On RHEL 7, tmux is an indispensable tool for remote server administration, long builds, log monitoring, and multi-tasking workflows.

Prerequisites

  • A RHEL 7 system with internet access or a configured YUM repository
  • A user account with sudo privileges
  • SSH access to the server (the primary use case for tmux)

Step 1: Installing tmux on RHEL 7

tmux is available in the standard RHEL 7 repositories. Install it with yum:

sudo yum install tmux

Verify the installation and check the version:

tmux -V

On RHEL 7 with standard repos, you will typically get tmux 1.8 or a similar version from that era. If you need a newer version, you can install it from the EPEL (Extra Packages for Enterprise Linux) repository:

# Install EPEL repository
sudo yum install epel-release

# Install a newer tmux version from EPEL
sudo yum install tmux

Step 2: Understanding the Prefix Key

All tmux keyboard shortcuts are triggered by first pressing a prefix key, which signals to tmux that the next keystroke is a command rather than regular input. The default prefix is Ctrl+b.

For example, to split the current pane horizontally, you press Ctrl+b, release both keys, then press %. Throughout this tutorial, the prefix will be written as prefix.

The prefix key is one of the first things many users change. A very common alternative is Ctrl+a (borrowed from GNU screen). To change it, you edit ~/.tmux.conf (covered in a later step).

Step 3: Working with Sessions

A tmux session is the top-level container. It persists on the server even when you disconnect. You can create multiple sessions, each with an independent set of windows and panes.

Starting a New Session

# Start a new unnamed session
tmux

# Start a new named session (recommended — easier to find later)
tmux new-session -s mysession

# Short form
tmux new -s mysession

Detaching from a Session

To detach from a session while leaving it running in the background:

prefix d

This returns you to your normal shell. The tmux session and all its processes continue running.

Listing Active Sessions

tmux list-sessions

# Short form
tmux ls

Example output:

mysession: 3 windows (created Mon May 17 10:00:00 2026) [220x50]
logs: 1 windows (created Mon May 17 09:30:00 2026) [220x50]

Attaching to a Session

# Attach to a named session
tmux attach-session -t mysession

# Short form
tmux a -t mysession

# If only one session exists, just type:
tmux attach

Killing a Session

# Kill a specific named session
tmux kill-session -t mysession

# Kill all sessions (use with care)
tmux kill-server

Step 4: Working with Windows

Within a session, you can have multiple windows, each occupying the full terminal area. Think of them like browser tabs.

  • prefix c — create a new window
  • prefix , — rename the current window
  • prefix n — move to the next window
  • prefix p — move to the previous window
  • prefix 0–9 — switch to window by number
  • prefix w — show an interactive list of all windows
  • prefix & — kill the current window (with confirmation)

The status bar at the bottom of the tmux screen shows all windows. The current window is marked with an asterisk (*).

Step 5: Working with Panes

Panes are subdivisions of a single window, allowing you to view multiple terminals side by side or stacked. This is extremely useful for monitoring logs in one pane while running commands in another.

  • prefix % — split the current pane vertically (side by side)
  • prefix " — split the current pane horizontally (top and bottom)
  • prefix arrow-key — move focus to the pane in that direction
  • prefix x — kill the current pane (with confirmation)
  • prefix z — toggle zoom on the current pane (temporarily full-screen it)
  • prefix q — briefly display pane numbers; press a number to jump to that pane
  • prefix { — swap the current pane with the previous one
  • prefix } — swap the current pane with the next one
  • prefix Ctrl+arrow — resize the current pane in small increments

A typical workflow: create a window, split it horizontally (prefix "), run a command in the top pane, and tail a log file in the bottom pane:

# In top pane
sudo yum update -y

# Switch to bottom pane (prefix ↓), then:
sudo tail -f /var/log/yum.log

Step 6: Using Copy Mode

tmux has a built-in copy mode that lets you scroll back through the terminal history and copy text, even in a session that predates your current connection. This is invaluable for capturing output from commands that have already finished.

prefix [     # Enter copy mode

In copy mode:

  • Use arrow keys or Page Up/Page Down to scroll
  • Press Space to begin selection
  • Move to end of desired text, then press Enter to copy
  • Press q to exit copy mode

To paste the copied buffer:

prefix ]

In vi-mode copy mode (configured in ~/.tmux.conf), use v to start selection and y to yank (copy), consistent with vim motions.

Step 7: Customizing tmux with ~/.tmux.conf

The ~/.tmux.conf file lets you customize key bindings, appearance, and behavior. Create it if it does not exist:

vi ~/.tmux.conf

A practical configuration for RHEL 7 administration:

# Change the prefix key from Ctrl+b to Ctrl+a
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# Enable mouse support (click to select panes/windows, resize panes)
set -g mouse on

# Use vi key bindings in copy mode
setw -g mode-keys vi

# Set scrollback buffer to 10000 lines
set -g history-limit 10000

# Start window and pane numbering at 1 (easier to reach on keyboard)
set -g base-index 1
setw -g pane-base-index 1

# Renumber windows when one is closed
set -g renumber-windows on

# Shorter escape time (useful when using vim inside tmux)
set -sg escape-time 10

# Status bar customization
set -g status-bg colour235
set -g status-fg white
set -g status-left '[#S] '
set -g status-right '%Y-%m-%d %H:%M'
set -g status-right-length 50

# Split panes using | and - (more intuitive)
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %

# Reload config without restarting tmux
bind r source-file ~/.tmux.conf ; display-message "Config reloaded!"

After saving, reload the config in a running tmux session:

prefix r    # if you added the reload binding above
# or:
tmux source-file ~/.tmux.conf

Step 8: Sharing Sessions Between Users

tmux supports shared sessions, where multiple users can simultaneously view and interact with the same terminal session. This is useful for pair programming, training, or collaborative troubleshooting.

To share a session, both users must be on the same system. User A creates a session with a socket accessible to User B:

# User A: create a session with a shared socket
tmux -S /tmp/shared-session new -s shared
chmod 777 /tmp/shared-session

User B then attaches to it:

# User B: attach to the shared session
tmux -S /tmp/shared-session attach -t shared

Both users now see the same terminal content and can type commands. For view-only access by the second user, attach in read-only mode:

tmux -S /tmp/shared-session attach -t shared -r

Conclusion

tmux is one of the most productivity-enhancing tools in a Linux administrator’s toolkit, particularly when managing RHEL 7 systems over SSH. You have learned how to install tmux, manage persistent sessions that survive disconnections, organize work across multiple windows and panes, navigate efficiently with keyboard shortcuts, use copy mode to review historical output, and customize tmux’s behavior through ~/.tmux.conf. Once you internalize the workflow of creating a named session for each major task and detaching cleanly when you step away, you will never want to manage a remote server without it. For advanced use, explore tmux plugins via the Tmux Plugin Manager (TPM) and the tmux-resurrect plugin, which can save and restore session state across server reboots.