tmux system
your terminal crashed. your work didn't.
The tmux man page is 3,200 lines long. You need about twenty minutes and you’ll never go back.
You SSH’d into a server. You started a long-running process. Your WiFi dropped for half a second. The process died. Your work is gone. You stared at “Connection reset by peer” like it personally betrayed you. You reconnected. You started over.
Or — hear me out — you could have typed tmux first and none of that would have happened.
tmux is a terminal multiplexer. That’s a fancy way of saying: it keeps your terminal sessions alive even when you disconnect. It also splits your terminal into panes, manages multiple windows, and generally makes you wonder how you ever lived without it.
Unless you’re running Windows — then what the hell are you doing here anyways?! If you want to join the party and understand what the hell we’re talking about, go install WSL2. We’ll wait. Impatiently.
Lazy sysadmins can skip straight to the cheat sheet.
The basics: sessions
A tmux session is a container for your work. It lives on the server. It doesn’t care about your WiFi. It doesn’t care about your laptop lid. It doesn’t care about you. It just keeps running.
Start a new session
tmux
You’re in. You’re now inside a tmux session. Everything you do from here survives a disconnect. That’s it. That’s the tweet.
Start a named session
tmux new -s work
Name your sessions. Future you will thank present you when you have three sessions running and need to remember which one has the production logs.
Detach from a session
Press Ctrl+b then d.
That’s the tmux prefix (Ctrl+b) followed by the command (d for detach). You just left the session, but it’s still running. Everything in it is still going. You can close your terminal. You can close your laptop. You can go home. The session doesn’t care.
List sessions
tmux ls
Shows you every session that’s running. Named sessions make this list readable. Unnamed sessions show up as 0:, 1:, 2: — which is about as helpful as it sounds.
Reattach to a session
tmux attach -t work
You’re back. Right where you left off. The process you started three hours ago? Still running. The log you were tailing? Still tailing. The universe continued without you and tmux kept the receipts.
Or if you only have one session:
tmux a
Two characters. You’re reconnected.
Kill a session
tmux kill-session -t work
When you’re done. Actually done. Not “I’ll come back to this” done.
Windows (tabs for your terminal)
Inside a session, you can have multiple windows. Think of them as tabs. Except your browser tabs eat 4GB of RAM and these eat approximately nothing.
Create a new window
Ctrl+b then c
A new window appears. The status bar at the bottom shows you all your windows.
Switch between windows
Ctrl+b then 0-9 — jump to window by number
Ctrl+b then n — next window
Ctrl+b then p — previous window
Rename a window
Ctrl+b then ,
Type a name. Hit enter. Now your status bar says “logs” instead of “3:bash” and you can actually find things.
Close a window
Type exit or Ctrl+d. The window closes. If it was the last window, the session ends.
Panes (splits, the thing you installed Terminator for)
This is where tmux replaces three separate terminal windows, Terminator, iTerm2 split panes, and that one person who tiles four PuTTY windows side by side on a 4K monitor and calls it “a workflow.”
Split horizontally
Ctrl+b then "
Your terminal splits top and bottom. Two shells. One window.
Split vertically
Ctrl+b then %
Left and right. You now have a split terminal. No application was installed. No config file was edited. Two keystrokes.
Move between panes
Ctrl+b then arrow keys.
That’s it. Left, right, up, down. You’re in a different pane.
Resize panes
Ctrl+b then hold Ctrl and press arrow keys.
Drag the border in whichever direction you want. Or if you want precision:
Ctrl+b then : then type resize-pane -D 10 (or -U, -L, -R for up, left, right).
Zoom a pane (full screen one pane temporarily)
Ctrl+b then z
The current pane goes full screen. Press it again and it goes back. This is for when you need to actually read something without squinting at a pane that’s 40 characters wide.
Close a pane
Ctrl+d or type exit. The pane disappears. The others resize to fill the space.
The SSH combo (the whole point)
Here’s the workflow that will change how you use remote servers forever:
1. SSH into the server
ssh myserver
2. Start or reattach to tmux
tmux a || tmux new -s main
That says “attach to an existing session, or if there isn’t one, create a new one called ‘main.’” One line. Memorize it. Tattoo it. Whatever.
3. Do your work
Run your processes. Tail your logs. Edit your configs. Split into panes. Go wild.
4. Detach and leave
Ctrl+b then d. Close your terminal. Close your laptop. Go to lunch. Go home. Go on vacation.
5. Come back whenever
ssh myserver
tmux a
Everything is exactly where you left it. Your long-running build? Done. Your log tail? Still going. Your three panes with the perfect layout? Untouched.
Your WiFi dropped mid-session? Doesn’t matter. SSH into the server again, tmux a, and you’re back. tmux didn’t even notice you were gone.
Common layouts
The monitoring setup
tmux new -s monitoring
Then split it up:
Ctrl+bthen"— horizontal splitCtrl+bthen%— vertical split on the bottom pane- Top pane:
htop - Bottom-left:
tail -f /var/log/syslog - Bottom-right: free shell for commands
┌─────────────────────────────┐
│ htop │
├──────────────┬──────────────┤
│ tail -f │ free shell │
│ syslog │ for you │
└──────────────┴──────────────┘
Detach from it. Come back tomorrow. It’s still there. Still monitoring. Still not giving a damn about your internet connection.
The development setup
tmux new -s dev
- Window 0: editor
- Window 1: running server / app
- Window 2: logs
- Window 3: git / general terminal
Rename each window (Ctrl+b then ,) so your status bar looks like:
[dev] 0:editor 1:server 2:logs 3:git
That’s four workspaces in one terminal. No tabs. No multiple windows. No alt-tabbing between six different things.
The key bindings that actually matter
Everything starts with Ctrl+b (the prefix). Then:
| Keys | What it does |
|---|---|
d |
Detach from session. It keeps running. |
c |
Create new window. |
n / p |
Next / previous window. |
0-9 |
Jump to window by number. |
, |
Rename current window. |
" |
Split pane horizontally (top/bottom). |
% |
Split pane vertically (left/right). |
| arrow keys | Move between panes. |
z |
Zoom current pane (toggle full screen). |
x |
Kill current pane (asks for confirmation). |
[ |
Scroll mode. Use arrow keys / PgUp / PgDn. Press q to exit. |
: |
Command mode. For when you need the fancy stuff. |
“But I already use—”
Sure you do.
“I use screen.” Screen hasn’t had a meaningful update since your car was new. tmux has vertical splits, scriptable layouts, better key bindings, and was written by people who apparently used screen and got angry about it. Which is the most relatable origin story for software ever written.
“I just open multiple terminal windows.” And then you alt-tab between twelve windows, lose track of which one has the logs, accidentally close the one running the build, and spend ten minutes getting back to where you were. tmux has one window with panes. You can see everything. At once.
“Terminator gives me split panes.” Terminator is a terminal emulator that splits. tmux is a session manager that splits. Close Terminator and your panes are gone. Close your terminal with tmux and your panes are still running on the server. These are not the same thing.
“iTerm2 has tmux integration.” iTerm2 is macOS only, 17MB, and its tmux integration is a way to use tmux through a GUI. Think about what you just said. You’re using a GUI to interface with a terminal tool. We’ve gone full circle.
“I don’t work on remote servers.” Cool. tmux is still useful locally. Your terminal crashes? tmux sessions survive. Need split panes? tmux. Need to organize six projects? tmux windows. It’s not just for SSH. It’s for anyone who uses a terminal and has ever lost work because something closed that shouldn’t have.
Cheat sheet
You made it. Or you skipped straight here. Either way, no judgment. Copy and paste these. Pin them. Tattoo them on your forearm. Whatever works.
Session commands (run in your normal shell):
| What you’re doing | Command |
|---|---|
| New session | tmux |
| New named session | tmux new -s name |
| List sessions | tmux ls |
| Attach to session | tmux attach -t name |
| Attach (only session) | tmux a |
| Attach or create | tmux a || tmux new -s main |
| Kill session | tmux kill-session -t name |
Inside tmux (prefix is Ctrl+b):
| What you’re doing | Keys |
|---|---|
| Detach | Ctrl+b then d |
| New window | Ctrl+b then c |
| Next window | Ctrl+b then n |
| Previous window | Ctrl+b then p |
| Jump to window N | Ctrl+b then 0-9 |
| Rename window | Ctrl+b then , |
| Split horizontal | Ctrl+b then " |
| Split vertical | Ctrl+b then % |
| Move between panes | Ctrl+b then arrow keys |
| Zoom pane | Ctrl+b then z |
| Kill pane | Ctrl+b then x |
| Scroll mode | Ctrl+b then [ |