If you're coming from screen and wondering whether tmux gives you the same "start a long-running job, disconnect, come back later" workflow: yes, it does. That's one of its core reasons for existing. Anything you start inside a tmux session keeps running when you detach, when your SSH connection drops, or when you close your laptop and go eat lunch.
This post walks through the mental model, the minimum set of commands you need to be productive, and a printable-ish cheat sheet you can keep next to the keyboard.
The mental model
tmux runs as a server process on the host. When you type tmux new, you're asking the server to spin up a session, which is a container for your work. A session holds one or more windows (think tabs), and each window holds one or more panes (split views of a terminal).
Your terminal emulator connects to the server as a client. Detaching just means disconnecting the client. The server keeps chugging along with everything you had running inside.
Sessions survive:
- SSH disconnects
- Closing your terminal
- Network blips
- You intentionally detaching with
Ctrl+b d
Sessions do not survive:
- A reboot of the host
- Someone running
tmux kill-server - The OOM killer deciding today is the day
If you need something to outlive a reboot, wrap it in a systemd unit. tmux is for interactive persistence, not durable service management.
The prefix key
Almost every tmux command starts with a prefix, which by default is Ctrl+b. You press Ctrl+b, release, then press the next key. I'll write this as C-b <key> from here on.
A lot of people remap this to Ctrl+a to match screen's muscle memory. If you want to do that, drop this in ~/.tmux.conf:
unbind C-b
set -g prefix C-a
bind C-a send-prefix
Then tmux kill-server and start fresh, or run tmux source-file ~/.tmux.conf from inside a session.
The basic workflow
Start a named session for whatever you're working on:
tmux new -s cosmos-build
Kick off your long-running thing. Tail logs. Run a deploy. Whatever.
Detach when you're done babysitting it:
C-b d
You're back at your shell. The session is still running. Check on it any time:
tmux ls
That'll show something like:
cosmos-build: 1 windows (created Sun Apr 19 09:14:22 2026)
Reattach when you come back:
tmux attach -t cosmos-build
If there's only one session, tmux attach with no arguments is enough. If you have a bunch, tab completion on the session name works nicely.
Windows and panes
Once you're inside a session, you can split your view or open additional "tabs" without leaving tmux.
Splits (panes):
C-b %splits the current pane vertically (side by side)C-b "splits horizontally (stacked)C-b <arrow>moves focus between panesC-b xkills the focused pane (with a confirmation prompt)C-b zzooms the focused pane to full screen, press again to unzoom
New windows (tabs):
C-b ccreates a new windowC-b n/C-b pcycles next and previousC-b 0throughC-b 9jumps to that window numberC-b ,renames the current windowC-b wshows a pickable list of windows
I use zoom (C-b z) more than I expected to. It's great for reading a stack trace without resizing.
Scrolling and copying
This is the one that trips up screen converts. Your mouse scroll wheel won't work by default inside a tmux pane because tmux is intercepting terminal events. To scroll back through output:
C-b [
That drops you into copy mode. Now you can use arrow keys, Page Up/Down, or Ctrl+u / Ctrl+d to move around. Press q to get out.
If you want the mouse to just work (scroll wheel, click to select panes, drag to resize splits), add this to ~/.tmux.conf:
set -g mouse on
Gotchas worth knowing
Double-attach flicker. If you SSH in from two places and both run tmux attach, both clients see the same session and fight over the screen size. Use tmux attach -d to kick off any existing client when you attach. Or tmux attach -r for read-only if you just want to watch.
Nested tmux. If you SSH from a tmux session into another box and run tmux there, your prefix key is now ambiguous. You have to press C-b twice to send it to the inner session. Some people set a different prefix for the outer tmux to avoid this entirely.
Terminal colors. If your colors look wrong inside tmux, start it with tmux -2 to force 256-color mode, or set set -g default-terminal "screen-256color" in your config. For true color support, you'll want tmux-256color plus the right terminfo entries, which is a whole separate rabbit hole.
Environment variables. tmux captures your shell environment when the session is created. If you update $PATH or add new SSH agent sockets later, existing panes won't see the change. Open a new pane or use tmux set-environment to update the session.
The cheat sheet
Default prefix is Ctrl+b. All commands below assume you press the prefix first unless marked [shell].
Sessions
| Command | What it does |
|---|---|
tmux new -s <name> [shell] |
Start a new named session |
tmux ls [shell] |
List running sessions |
tmux attach -t <name> [shell] |
Attach to a session |
tmux attach -d -t <name> [shell] |
Attach and detach other clients |
tmux kill-session -t <name> [shell] |
Kill a specific session |
tmux kill-server [shell] |
Nuclear option, kills everything |
d |
Detach from current session |
$ |
Rename current session |
s |
Pick a session from a list |
Windows
| Command | What it does |
|---|---|
c |
Create a new window |
, |
Rename current window |
n / p |
Next / previous window |
0-9 |
Jump to window by number |
w |
List windows, pick one |
& |
Kill current window |
f |
Find window by text |
Panes
| Command | What it does |
|---|---|
% |
Split vertically (left/right) |
" |
Split horizontally (top/bottom) |
<arrow> |
Move between panes |
o |
Cycle through panes |
z |
Zoom current pane toggle |
x |
Kill current pane |
{ / } |
Swap pane with previous / next |
C-<arrow> |
Resize pane (hold Ctrl) |
! |
Break pane out into its own window |
q |
Briefly show pane numbers |
Copy mode and scrollback
| Command | What it does |
|---|---|
[ |
Enter copy mode |
q |
Exit copy mode |
/ |
Search forward (inside copy mode) |
? |
Search backward (inside copy mode) |
Space |
Start selection (inside copy mode) |
Enter |
Copy selection (inside copy mode) |
] |
Paste most recent buffer |
Config and misc
| Command | What it does |
|---|---|
: |
Open the tmux command prompt |
? |
Show all key bindings |
t |
Show a big clock in the pane (yes really) |
tmux source ~/.tmux.conf [:prompt] |
Reload config without restarting |
Minimum viable .tmux.conf
If you want a starting point that fixes the most annoying defaults without going full rice:
# Remap prefix to Ctrl+a (screen muscle memory)
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# Mouse works as expected
set -g mouse on
# Start window and pane numbering at 1
set -g base-index 1
setw -g pane-base-index 1
# Bigger scrollback buffer
set -g history-limit 50000
# Reload config with prefix + r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# Split panes using | and - (more intuitive than % and ")
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
Drop that in ~/.tmux.conf, reload, and you've got a setup that'll feel reasonable without being weird for anyone else who has to share your machine.
When to reach for tmux vs. something else
tmux is the right answer when you want:
- A long-running interactive process that survives SSH disconnects
- Multiple terminals on one remote host without opening a bunch of SSH connections
- To share a live terminal session with a coworker (via
tmux attachon the same user)
It's the wrong answer when you want:
- A service that survives reboots, use systemd
- Background process management on a desktop, use your window manager or a terminal multiplexer plugin
- Production job scheduling, use cron or a real scheduler
For day-to-day ops work though? You'll open tmux, kick off a thing, detach, and forget it's even there. That's the magic.