Terminal Multiplexing with Tmux
When working on a remote HPC cluster, your connection can occasionally drop due to Wi-Fi instability, VPN timeouts, or putting your laptop to sleep. Normally, a disconnection kills your remote terminal session and aborts any active text editing, file transfers, or interactive terminal work.
Tmux (Terminal Multiplexer) solves this by letting you start a session that lives entirely on the cluster's login node. If you get disconnected, your programs keep running in the background, and you can reattach to exactly where you left off.
⚠ HPC Policy Note
Tmux should only be used on login nodes for managing text editing, data transfers, or tracking jobs. Do not run heavy computational scripts or simulations directly inside a Tmux session on a login node. Always use SLURM interactive sessions (srun) for heavy workloads.
Core Concepts
Tmux operates on a simple structural hierarchy:
- Session: A persistent environment that survives network disconnections. You can run multiple independent sessions tracking different projects.
- Window: Equivalent to a "tab" in a web browser, contained completely within a session.
- Pane: A single active window split vertically or horizontally into multiple distinct, concurrent terminal screens.
Basic Commands (Terminal CLI)
Run these commands directly in your standard cluster terminal prompt before entering a multiplexer session.
| Action | Command |
|---|---|
| Start a new session (generic name) | tmux |
| Start a named session (Recommended) | tmux new -s my_project |
| List running sessions | tmux ls |
| Reattach to an ongoing active session | tmux a -t my_project |
| Kill / Delete a specific running session | tmux kill-session -t my_project |
Managing Tmux from Inside the Session
Once you are inside an active Tmux environment, all internal layout controls require you to execute a Prefix keyboard shortcut combination first, followed immediately by a tactical command key.
The Default Prefix Key Shortcut is: Ctrl + b
To trigger a command, press Ctrl and b at the same time, release them, and then immediately press the next assigned key layout.
1. Detaching (The most critical command)
To safely leave your entire workspace processing reliably in the background so you can log out of the cluster framework:
Ctrl + b, then press d
2. Managing Panes (Splitting your screen)
You can segment a single viewport window into multiple live independent terminal frames:
- Split Vertically (Side-by-side): Press Ctrl + b then press %
- Split Horizontally (Top-and-bottom): Press Ctrl + b then press "
- Switch between active panes: Press Ctrl + b then use the standard directional arrow keys (↑, ↓, ←, →)
- Close current pane: Press Ctrl + d (or type exit)
3. Managing Windows (Full Tabs)
If your screen gets cluttered with small panes, create clean full-screen browser-style tabs:
- Create a new window: Press Ctrl + b then press c
- Next window tab: Press Ctrl + b then press n
- Previous window tab: Press Ctrl + b then press p
- Jump to a specific numeric window: Press Ctrl + b then type the target integer index 0-9 (visible in the lower dashboard layout bar)
Copying and Scrolling Text (Mouse Mode)
By default, rolling your system mouse wheel inside an active Tmux environment will not scroll your standard terminal output buffer history. To check old print logs or copy text arrays, enter Copy Mode:
Press Ctrl + b then press [
You can now utilize your hardware directional keyboard arrow keys or Page Up / Page Down modules to scroll back through the printed timeline array. To terminate scroll tracking and safely return back to your live interactive prompt buffer, simply press q.
Pro-Tip: Enable Native Mouse Support
If you prefer using your terminal mouse interface to navigate buffers and snap directly between split display frames, execute this setup string directly inside your active Tmux window line:
tmux set -g mouse onNote: To make this configuration change persistent across logins, append the configuration string set -g mouse on directly into a text file labeled .tmux.conf located directly within your root home user directory space.
Typical HPC Workflow Example
1. Log into the cluster using a clean SSH connection path:
ssh username@scu-login01.med.cornell.edu2. Instantiate a explicitly named Tmux workspace allocation target for pipeline tasks:
tmux new -s rna_sequencing3. Initialize a code editor workspace frame, file transfer pipeline, or monitor an ongoing live SLURM scheduler tracking queue:
watch squeue -u username4. Safely detach from the remote frame by holding down Ctrl + b then pressing d. You can now completely disconnect your VPN link, safely close down your notebook hardware, and travel home.
5. The next morning, log back into the main university cluster endpoint and instantly restore your context:
tmux a -t rna_sequencing