tmux is a terminal multiplexer that lets you run multiple shell sessions inside a single terminal window, keep sessions alive after you disconnect from SSH, and split your screen into panes for simultaneous work. On RHEL 8 it is available from the default AppStream repository and requires no additional configuration to get started. This tutorial covers installation, essential key bindings, window and pane management, detaching and reattaching named sessions, and a basic ~/.tmux.conf that enables mouse support and improves the status bar.

Prerequisites

  • A running RHEL 8 system with internet or repository access
  • A user account with sudo privileges
  • Basic familiarity with the Bash command line

Step 1 — Installing tmux

tmux is shipped in the RHEL 8 AppStream repository, so installation is a single dnf command. If your system is registered with Red Hat Subscription Manager the package is available immediately; EPEL is not required.

# Install tmux
sudo dnf install -y tmux

# Verify the installed version
tmux -V

# Start your first session
tmux

Step 2 — Understanding the Prefix Key and Essential Bindings

Every tmux command begins with the prefix key, which is Ctrl+b by default. Press the prefix, release it, then press the command key. The table below lists the bindings you will use most frequently. If you mistype, pressing Ctrl+b again cancels and returns you to the normal shell.

# Key bindings reference (press Ctrl+b first, then the key below)
# ?       — list all key bindings
# d       — detach from current session
# c       — create a new window
# n       — next window
# p       — previous window
# ,       — rename current window
# %       — split pane vertically (left/right)
# "       — split pane horizontally (top/bottom)
# Arrow   — move between panes
# x       — kill current pane (confirm with y)
# &       — kill current window (confirm with y)
# [       — enter scroll / copy mode (q to exit)

Step 3 — Managing Windows and Panes

Windows in tmux function like browser tabs — each holds one or more panes. Panes divide a window into independent terminal areas. You can resize panes by holding the prefix and pressing an arrow key repeatedly, or run the resize command directly.

# Create a new window
# Ctrl+b  c

# Rename the current window
# Ctrl+b  ,   then type a name and press Enter

# Split window into left and right panes
# Ctrl+b  %

# Split window into top and bottom panes
# Ctrl+b  "

# Navigate between panes
# Ctrl+b  Arrow key

# Resize current pane (repeat arrow to resize incrementally)
# Ctrl+b  Ctrl+Arrow

# Close current pane
# Ctrl+b  x   (press y to confirm)

Step 4 — Detaching and Reattaching Sessions

The most valuable tmux feature for remote work is session persistence. When you detach, your programs keep running inside tmux even after your SSH connection drops. Reconnect later and reattach to pick up exactly where you left off.

# Start a new named session
tmux new -s mysession

# Detach from the current session (programs keep running)
# Ctrl+b  d

# List all running sessions
tmux list-sessions

# Reattach to a named session
tmux attach -t mysession

# Reattach to the most recent session
tmux attach

# Rename an existing session from outside tmux
tmux rename-session -t mysession production

# Kill a session cleanly
tmux kill-session -t mysession

Step 5 — Configuring ~/.tmux.conf

tmux reads ~/.tmux.conf at startup. The configuration below enables mouse support so you can click panes and scroll with the wheel, increases the scrollback buffer, sets a 256-color terminal, and improves the status bar with a clock and session name. After saving, reload without restarting tmux using the source-file command.

cat > ~/.tmux.conf <<'EOF'
# Enable mouse (click to select pane, scroll wheel for history)
set -g mouse on

# Increase scrollback buffer
set -g history-limit 10000

# Use 256 colors
set -g default-terminal "screen-256color"

# Status bar: show session name, windows, and clock
set -g status-bg colour235
set -g status-fg colour255
set -g status-left "[#S] "
set -g status-right " %Y-%m-%d %H:%M "
set -g status-right-length 30

# Start windows and panes at index 1 instead of 0
set -g base-index 1
setw -g pane-base-index 1
EOF

# Reload configuration without restarting tmux
tmux source-file ~/.tmux.conf
# Or from inside tmux:
# Ctrl+b  :   source-file ~/.tmux.conf

Step 6 — Practical Session Workflow

A common pattern is to create one named tmux session per project with dedicated windows for editing, running, and logs. The commands below demonstrate a complete workflow you can adapt to your own projects.

# Start a new project session
tmux new -s webproject

# Create a window for the editor (Ctrl+b c), rename it
# Ctrl+b c
# Ctrl+b ,  →  type "editor"  →  Enter

# Create another window for logs
# Ctrl+b c
# Ctrl+b ,  →  type "logs"  →  Enter

# Split the logs window: top for app log, bottom for syslog
# Ctrl+b "
# In top pane: sudo journalctl -u myapp -f
# Move to bottom pane: Ctrl+b Down
# In bottom pane: sudo tail -f /var/log/messages

# Detach and leave everything running
# Ctrl+b d

# Check all sessions from outside
tmux list-sessions

# Reattach later
tmux attach -t webproject

Conclusion

You have installed tmux on RHEL 8, learned the prefix-key model, created and navigated windows and panes, detached and reattached named sessions, and written a practical ~/.tmux.conf with mouse support and a useful status bar. tmux transforms how you work on remote servers — long-running tasks survive disconnects, and a logical window layout keeps multiple workstreams organized in a single SSH session.

Next steps: How to Set Up a Bash Profile and Environment Variables on RHEL 8, How to Configure Log Rotation with logrotate on RHEL 8, and How to Manage Systemd Services and Units on RHEL 8.