The Problem: Opening 10 Terminal Tabs Only to Lose Them All When SSH Disconnects
When I first started working with Linux servers, I had a habit of opening dozens of terminal tabs to monitor logs, run commands, and edit files — one tab per task. It looked impressive but was actually a complete mess. Then one day I SSHed into a VPS to deploy something, and right in the middle of the process, the network went down. The connection dropped, the build process died, and I had to start over from scratch. It was painful.
That build took 20 minutes. The second attempt ran into different errors because the environment was left in a broken state. After that incident, I learned an expensive lesson — and tmux is now the first thing I install on any new server.
Standard Terminals: Two Fatal Weaknesses
There are two core problems that standard terminals (or plain SSH) simply cannot solve:
- No persistent sessions: When an SSH connection drops (network outage, laptop sleep, timeout), every running process gets killed immediately.
- No window management: Multiple SSH tabs mean multiple separate connections, with no way to get an overview or quickly switch between tasks.
Juniors often reach for nohup or & to run things in the background — fine for one or two simple commands. But when projects get more complex (monitoring logs, running a server, and editing configs simultaneously), nohup doesn’t cut it.
Comparing Your Options
Option 1: Use nohup or screen
nohup keeps a process running after logout, but gives you no interface to interact with it again. screen is better — it creates persistent sessions with attach/detach support — but the interface feels dated, the shortcuts are hard to remember, and it lacks tmux’s split-pane capabilities.
Option 2: Open Multiple Parallel SSH Connections
It works, but wastes resources. An unstable network will still wipe everything out at once. It doesn’t address the root problem.
Option 3: Use tmux
tmux (terminal multiplexer) lets you:
- Create sessions that persist independently of the SSH connection
- Split a single terminal window into multiple panes
- Switch quickly between windows and sessions
- Detach and reattach at any time, from any machine
Mastering tmux Step by Step
Step 1: Install tmux
On most Linux distros, tmux is available in the package manager:
# Ubuntu / Debian
sudo apt update && sudo apt install tmux -y
# CentOS / RHEL / Fedora
sudo dnf install tmux -y
# Arch Linux
sudo pacman -S tmux
# Check version
tmux -V
tmux 3.x and above supports mouse input and includes significant improvements. Run tmux -V — if you see tmux 3.2a or higher, you’re good to go.
Step 2: Understand tmux’s Three-Level Structure
Before typing any commands, get these three concepts straight:
- Session: The top-level container. A session can hold multiple windows and persists even when you detach.
- Window: Equivalent to a tab in a terminal. Each window occupies the full screen.
- Pane: A window can be split into multiple panes, each acting as an independent terminal.
Think of it this way: a Session is an office building, Windows are individual rooms, and Panes are the desks inside each room.
Step 3: Basic Commands from Outside tmux
# Create a new session (unnamed)
tmux
# Create a session with a specific name (recommended)
tmux new-session -s deploy
tmux new -s monitoring # shorthand
# List all running sessions
tmux ls
# Attach to a session by name
tmux attach -t deploy
tmux a -t deploy # shorthand
# Attach to the most recent session
tmux a
# Kill a session
tmux kill-session -t deploy
Step 4: Shortcuts Inside tmux
Every tmux command starts with the prefix key — defaulting to Ctrl + b. Press the prefix, release it, then press the command key. Do not hold all three keys simultaneously.
Example: to create a new window, press Ctrl+b, release, then press c.
Session Management:
Ctrl+b d # Detach from session (session keeps running in background)
Ctrl+b $ # Rename current session
Ctrl+b s # View session list (select to switch)
Window Management:
Ctrl+b c # Create a new window
Ctrl+b , # Rename current window
Ctrl+b n # Switch to next window
Ctrl+b p # Switch to previous window
Ctrl+b 0-9 # Jump directly to window 0, 1, 2...
Ctrl+b w # View window list to select
Ctrl+b & # Close current window (with confirmation)
Pane Management:
Ctrl+b % # Split screen vertically
Ctrl+b " # Split screen horizontally
Ctrl+b arrow # Move between panes
Ctrl+b z # Zoom current pane (toggle fullscreen)
Ctrl+b x # Close current pane (with confirmation)
Ctrl+b q # Show pane numbers
Ctrl+b { # Move pane to the left
Ctrl+b } # Move pane to the right
Step 5: A Real-World Deploy Scenario
Here’s how I typically deploy a Node.js application to a VPS:
# SSH into the server
ssh user@vps-ip
# Create a session named 'deploy'
tmux new -s deploy
# Split pane: run deploy command on the left, watch logs on the right
Ctrl+b %
# Left pane: run the deploy script
git pull origin main && npm install && pm2 restart app
# Switch to right pane (Ctrl+b →)
# Right pane: watch logs in real time
pm2 logs app --lines 50
# If the network drops, SSH back in and reattach to the old session
tmux a -t deploy
# Everything is still there!
I once deployed an app with a 15-minute build pipeline. The network cut out mid-way, I SSHed back in, attached to the session — the build was still running, the logs were all there, nothing was lost.
Step 6: Customize tmux with a Config File
The config file lives at ~/.tmux.conf. The minimal config below is a solid starting point:
# Change prefix from Ctrl+b to Ctrl+a (more familiar for GNU screen users)
# set-option -g prefix C-a
# unbind C-b
# bind C-a send-prefix
# Enable mouse — scroll and click to select panes
set -g mouse on
# Number windows starting from 1 instead of 0 (more natural on the keyboard)
set -g base-index 1
setw -g pane-base-index 1
# Increase scrollback buffer to 5000 lines (default is 2000)
set -g history-limit 5000
# Status bar shows hostname and time
set -g status-right '%Y-%m-%d %H:%M'
set -g status-right-length 30
# Reload config without restarting tmux
bind r source-file ~/.tmux.conf \; display "Config reloaded!"
After editing, reload the config with:
# Inside tmux, press:
Ctrl+b r
# Or from outside:
tmux source-file ~/.tmux.conf
Step 7: Multi-Session Workflow for Multiple Projects
Each project or server should have its own session — organized this way, Ctrl+b s brings up a handy session selection menu:
# One session per project/server
tmux new -s itfromzero # Main blog
tmux new -s monitoring # Server monitoring
tmux new -s staging # Staging environment
# Get an overview of everything
tmux ls
# itfromzero: 3 windows (created Fri Feb 28 09:00:00 2026)
# monitoring: 1 windows (created Fri Feb 28 08:30:00 2026)
# staging: 2 windows (created Fri Feb 28 10:15:00 2026)
# Switch between sessions from inside tmux
Ctrl+b s # Show session selection menu
Wrapping Up
Around 10 shortcuts will cover 80% of your daily work. No need to learn everything at once.
Suggested learning path:
- Install tmux, create a named session
- Practice detaching (
Ctrl+b d) and reattaching (tmux a -t name) - Learn pane splitting (
Ctrl+b %andCtrl+b ") - Add
set -g mouse onto~/.tmux.confto enable mouse support - Gradually explore more features as you need them
The most effective way to learn is to use tmux in your actual work — the next time you SSH into a server, open tmux right away. After a few weeks, the shortcuts will become muscle memory and you won’t need to glance at a cheatsheet anymore.

