tmux vs screen — Complete Comparison & tmux Deep Dive
What is a Terminal Multiplexer?
A terminal multiplexer lets you manage multiple terminal sessions within a single window. It allows you to:
- Keep programs running in the background even after closing your terminal
- Split a terminal window into multiple panes
- Detach and reattach to sessions seamlessly
- Share a session with other users for pair programming
The two most popular choices are GNU Screen and tmux.
A Brief History
Screen was released in 1987 as part of the GNU project — the grandparent of terminal multiplexers. It ships pre-installed on virtually every Linux distribution.
tmux was created in 2007 by Nicholas Marriott (an OpenBSD developer). Screen’s codebase had grown stale and hard to maintain; tmux was designed from scratch with a cleaner, more modern architecture and BSD licensing.
Screen vs tmux: Feature Comparison
| Feature | Screen | tmux |
|---|---|---|
| First release | 1987 | 2007 |
| Config file | ~/.screenrc |
~/.tmux.conf |
| Default prefix | Ctrl+a |
Ctrl+b |
| Vertical split | Patch required | Native |
| Horizontal split | Native | Native |
| Status bar | Off by default, needs config | Built-in, feature-rich |
| 256 colors | Requires screen-256color |
Default |
| True color | No | Yes |
| Copy mode | vi/emacs | vi/emacs |
| Scripting | Limited | Flexible (send-keys, etc.) |
| Plugin ecosystem | Minimal | TPM, tmux-resurrect, etc. |
| Session persistence | None | tmux-resurrect plugin |
| Buffer management | Basic | Advanced |
| Cross-platform | Almost everywhere | Almost everywhere |
| License | GPL | BSD |
Bottom line: For basic detach/attach in a single window, both are fine. For splits, customization, and scripting, tmux is the clear winner.
Installing tmux
1 | # macOS |
Verify:
1 | tmux -V # e.g. tmux 3.5 |
Core Concepts
tmux has a three-tier architecture:
1 | tmux |
Session: An independent workspace. You can have multiple sessions, each with its own set of windows.
Window: Like a tab — fills the entire terminal.
Pane: A split region within a window. Panes can be tiled horizontally, vertically, or in complex layouts.
All interactive commands start with the Prefix Key (default Ctrl+b).
Session Management
Command-line
1 | # Create and attach |
Key Bindings (inside tmux)
| Keys | Action |
|---|---|
Prefix d |
Detach from session |
Prefix s |
Interactive session picker |
Prefix $ |
Rename current session |
Prefix ( |
Switch to previous session |
Prefix ) |
Switch to next session |
Prefix L |
Switch to last session |
Window Management
| Keys | Action |
|---|---|
Prefix c |
Create new window |
Prefix , |
Rename current window |
Prefix w |
Interactive window picker |
Prefix p |
Previous window |
Prefix n |
Next window |
Prefix 0–9 |
Go to Nth window |
Prefix l |
Go to last active window |
Prefix & |
Close current window |
Prefix . |
Move current window (prompt for index) |
Prefix f |
Search window by title |
Pane Management
This is where tmux truly shines over Screen.
Creating Panes
| Keys | Action |
|---|---|
Prefix % |
Split vertically (left/right) |
Prefix " |
Split horizontally (top/bottom) |
Navigation
| Keys | Action |
|---|---|
Prefix o |
Cycle to next pane |
Prefix ↑/↓/←/→ |
Move to pane in direction |
Prefix ; |
Toggle to last active pane |
Prefix q |
Show pane numbers, press one to jump |
Prefix { |
Swap pane left |
Prefix } |
Swap pane right |
Resizing
| Keys | Action |
|---|---|
Prefix Ctrl+↑/↓/←/→ |
Resize by 1 cell |
Prefix Alt+↑/↓/←/→ |
Resize by 5 cells |
Prefix z |
Zoom pane in/out (fullscreen toggle) |
Prefix space |
Cycle through layouts |
Other Pane Operations
| Keys | Action |
|---|---|
Prefix x |
Kill current pane |
Prefix ! |
Break pane into a new window |
Prefix Ctrl+o |
Rotate all panes forward |
Prefix Alt+o |
Rotate all panes backward |
Synchronized Input
Send the same keystrokes to every pane at once:
1 | Prefix : setw synchronize-panes on # enable |
Copy Mode
1 | Prefix [ # enter copy mode |
Navigate with vi or emacs keys (default: emacs, switch with setw -g mode-keys vi):
| vi | emacs | Action |
|---|---|---|
h/j/k/l |
C-b/C-n/C-p/C-f |
Move cursor |
w/b |
M-f/M-b |
Word jump |
Ctrl-u/Ctrl-d |
Ctrl-u/Ctrl-d |
Half-page scroll |
gg/G |
M-< / M-> |
Start/end of buffer |
v |
Ctrl-space |
Begin selection |
y |
Ctrl-w |
Yank (copy) |
q |
Escape |
Exit copy mode |
Paste: Prefix ]
Configuring tmux (~/.tmux.conf)
tmux reads configuration from ~/.tmux.conf (or ~/.config/tmux/tmux.conf).
Here’s a production-ready configuration:
1 | # ==================== Base Settings ==================== |
Reload after editing:
1 | tmux source-file ~/.tmux.conf |
Advanced Techniques
1. tmux-resurrect + tmux-continuum: Session Persistence
These plugins let you save and restore tmux sessions across reboots.
1 | # Install TPM (Tmux Plugin Manager) |
Add to ~/.tmux.conf:
1 | set -g @plugin 'tmux-plugins/tpm' |
Install plugins: Prefix + I (capital I).
Usage:
Prefix Ctrl+s— save manuallyPrefix Ctrl+r— restore- tmux-continuum auto-saves every 15 minutes
2. Pair Programming
Multiple users can attach to the same tmux session simultaneously.
1 | # User A creates the session |
3. Vim/Neovim Integration
Use the same Ctrl+hjkl bindings to navigate both tmux panes and Vim windows:
In ~/.tmux.conf:
1 | bind -n C-h select-pane -L |
In ~/.vimrc:
1 | tnoremap <C-h> <C-\><C-n><C-w>h |
4. Scripted Workspace Setup
Automate your development environment:
1 |
|
5. Quick inline command pane
1 | # Open a temporary pane and close after command runs |
6. Buffer Management
1 | Prefix : list-buffers # list all paste buffers |
7. Nested tmux
When running tmux inside tmux (e.g., SSH into a remote server that also uses tmux):
1 | # Double-tap prefix to send one prefix to inner session |
8. Session Info at a Glance
1 | tmux list-sessions -F "#S: #{session_windows} windows [#{session_width}x#{session_height}] (#{session_created_string})" |
FAQ
Q: True color support
1 | # In ~/.tmux.conf: |
Verify with:
1 | curl -s https://gist.githubusercontent.com/lifepillar/09a44b8cf0f9397465614e622979107f/raw/24-bit-color.sh | bash |
Q: Auto-attach to last session on terminal open?
1 | # In ~/.zshrc or ~/.bashrc |
Q: How to open new panes/windows in the current directory?
Use the -c "#{pane_current_path}" flag in your bindings (already included in the config above).
Conclusion
| Use Case | Recommendation |
|---|---|
| Stable remote session persistence | Both work; Screen is sufficient |
| Split panes, multi-window workflows | tmux |
| Long-running headless server tasks | Screen (lighter) |
| Vim-style pane navigation | tmux |
| Session save/restore across reboots | tmux + tmux-resurrect |
| Legacy systems | Screen (pre-installed) |
| Modern config & plugin ecosystem | tmux |
If you’re new to terminal multiplexers, start with tmux. Its learning curve is slightly steeper than Screen, but the content in this guide covers everything you need — from first launch to daily mastery. Spend an hour tuning your .tmux.conf, and every workday after will feel noticeably more efficient.