If you spend time working on remote servers, running long-lived processes, or managing multiple terminals, tmux is one of the most valuable tools you can learn.
It allows you to keep terminal sessions alive even after disconnecting from SSH, split your terminal into multiple panes, organize work into windows, and switch between projects without opening dozens of terminal tabs.
This article is a practical cheat sheet covering the commands I use every day.
What is tmux?
tmux (Terminal Multiplexer) lets you create persistent terminal sessions.
Instead of opening multiple terminal windows, you can organize everything inside a single terminal.
Typical use cases:
- Remote server administration
- Backend development
- Running long-lived processes
- Docker and Kubernetes management
- DevOps workflows
- Multiple SSH connections
Sessions
A session is your workspace.
Think of it as a project that contains multiple windows and panes.
List sessions
tmux ls
# or
tmux list-sessions
Example:
backend: 2 windows
devops: 4 windows
Create a session
tmux new -s backend
Create a detached session
Useful for starting background services.
tmux new -d -s backend
Attach to a session
tmux attach -t backend
## Short version
tmux a -t backend
Detach from a session
Press
Ctrl+b d
Everything continues running.
Create or attach (my favorite)
Instead of remembering whether the session already exists:
tmux new -As backend
This creates the session if needed or attaches to it if it already exists.
Rename a session
tmux rename-session -t backend api
Or inside tmux:
Ctrl+b $
Kill a session
tmux kill-session -t backend
Kill every session:
tmux kill-server
Windows
A window is similar to a browser tab.
One session can contain many windows.
Create a new window
Ctrl+b c
List windows
Ctrl+b w
Next / Previous window
Ctrl+b n
Ctrl+b p
Jump directly
Ctrl+b 0
Ctrl+b 1
Ctrl+b 2
...
Rename window
Ctrl+b ,
Close window
Ctrl+b &
Panes (Split Terminals)
Panes let you divide a window into multiple terminals.
Vertical split
Creates left/right panes.
Ctrl+b %
+-----------+-----------+
| | |
| | |
+-----------+-----------+
Horizontal split
Creates top/bottom panes.
Ctrl+b "
+-----------------------+
| |
+-----------------------+
| |
+-----------------------+
Navigate Between Panes
Arrow keys:
Ctrl+b ←
Ctrl+b →
Ctrl+b ↑
Ctrl+b ↓
Cycle through panes:
Ctrl+b o
Show pane numbers:
Ctrl+b q
Resize Panes
Using the keyboard:
Ctrl+b Alt+Arrow
Or command mode:
Ctrl+b :
resize-pane -L 10
resize-pane -R 10
resize-pane -U 5
resize-pane -D 5
Zoom a Pane
Need temporary full-screen?
Ctrl+b z
Press again to restore.
Change Layout
Cycle through built-in layouts.
Ctrl+b Space
Very useful when several panes become cluttered.
Close a Pane
Simply exit the shell.
exit
or
Ctrl+d
Enable Mouse Support
Add this to your ~/.tmux.conf
set -g mouse on
Reload:
tmux source-file ~/.tmux.conf
Now you can:
- Click panes
- Resize panes
- Scroll normally
- Select windows with the mouse
Run Commands in Background
Launch a process without attaching.
tmux new -d -s api "npm run dev"
or
tmux new -d -s server "python app.py"
Perfect for servers and CI scripts.
A Typical Development Workflow
Suppose you're working on a backend application.
Session: backend
│
├── Window 0: Editor
│ ├── Neovim
│ ├── npm run dev
│ └── Logs
│
├── Window 1: Database
│ ├── PostgreSQL
│ └── Redis
│
└── Window 2: Monitoring
├── htop
└── Docker logs
Everything stays organized inside a single tmux session.
Disconnect from SSH?
No problem.
Reconnect later:
tmux attach -t backend
Everything is exactly where you left it.
Daily Cheat Sheet
| Action | Shortcut / Command |
|---|---|
| New session | tmux new -s name |
| Attach | tmux a -t name |
| Create or attach | tmux new -As name |
| List sessions | tmux ls |
| Detach | Ctrl+b d |
| New window | Ctrl+b c |
| Window list | Ctrl+b w |
| Next window | Ctrl+b n |
| Previous window | Ctrl+b p |
| Vertical split | Ctrl+b % |
| Horizontal split | Ctrl+b " |
| Switch panes | Ctrl+b + Arrow Keys |
| Next pane | Ctrl+b o |
| Zoom pane | Ctrl+b z |
| Change layout | Ctrl+b Space |
| Show pane numbers | Ctrl+b q |
| Close pane | Ctrl+d |
| Close window | Ctrl+b & |
| Kill session | tmux kill-session -t name |
Final Thoughts
Learning tmux takes a little practice, but once it becomes part of your workflow, it's hard to imagine working without it—especially when developing on remote servers or juggling multiple services.
Start with just a few shortcuts:
Ctrl+b dCtrl+b cCtrl+b %Ctrl+b "Ctrl+b zCtrl+b o
Master those, and you'll already be more productive than constantly opening and switching between terminal tabs.
Top comments (0)