If you live in the terminal — especially if you SSH into servers — you've probably felt the pain of a dropped connection killing a long-running job, or juggling five terminal tabs just to watch logs in one and edit a file in another. tmux fixes both. It's a terminal multiplexer: a program that lets one terminal window hold many shells, split into panes, and — best of all — keep running even after you disconnect.
Let me show you why it's worth installing and the handful of commands you'll actually use every day.
What tmux gives you
Here's what makes it stick once you try it:
- Sessions that survive disconnects. This is the big one. Start a job inside tmux on a remote server, close your laptop, and the session keeps running on the server. Reconnect later and pick up exactly where you left off — nothing lost. No more
nohupgymnastics or a broken SSH knocking out a 3-hour build. - Split panes. Divide one window into several side-by-side or stacked shells. Edit on the left, tail logs on the right, run a build at the bottom — all in one screen.
- Multiple windows. Like tabs, but in your terminal. One window per task, switch instantly.
- Detach and reattach. Step away, come back, same layout. You can even attach the same session from two machines at once — handy for pairing.
- It's keyboard-driven and scriptable. Once the shortcuts are in your fingers, it's faster than reaching for the mouse, and you can script whole layouts.
Here's the mental model at a glance — a session holds windows, and each window splits into panes:
If you already set up passwordless SSH, tmux is the natural next step — the two together make working on a remote box feel local.
Installing it
On Debian / Ubuntu:
sudo apt install tmux
On Fedora / RHEL:
sudo dnf install tmux
On macOS (with Homebrew):
brew install tmux
Start it by just typing tmux. You'll get a normal shell with a status bar across the bottom — that bar is how you know you're "inside" tmux.
The prefix key — the one thing to understand first
Almost every tmux command starts with a prefix key, then a second key. The default prefix is Ctrl-b (hold Ctrl, press b, let go, then press the command key).
So when I write prefix c below, that means: press Ctrl-b, release, then press c.
Note: This guide assumes the default
Ctrl-bthroughout.
Want an easier prefix? Remap it
Ctrl-b is an awkward reach. A popular swap is Ctrl-a (the old GNU Screen default). Add this to ~/.tmux.conf:
unbind C-b
set -g prefix C-a
bind C-a send-prefix
That last line means you can still send a literal Ctrl-a (handy for the shell's "jump to start of line") by pressing it twice. Reload without restarting: press prefix : and run source-file ~/.tmux.conf.
Sessions
These you type at the shell, not with the prefix:
tmux # start a new unnamed session
tmux new -s work # start a new session named "work"
tmux ls # list running sessions
tmux attach -t work # reattach to the "work" session
tmux kill-session -t work # end the "work" session
And the one you'll use constantly — detaching from inside a session is prefix d (the session keeps running in the background). Detach, log off, come back tomorrow, tmux attach, and it's all still there.
Windows (like tabs)
prefix c # create a new window
prefix n # next window
prefix p # previous window
prefix 0-9 # jump to window by number
prefix , # rename the current window
prefix w # list/choose windows
prefix & # close the current window
Panes (splitting one window)
prefix % # split vertically (left / right)
prefix " # split horizontally (top / bottom)
prefix arrow # move to the pane in that direction
prefix o # cycle to the next pane
prefix z # zoom the current pane to fullscreen (press again to unzoom)
prefix x # close the current pane
prefix space # cycle through pane layouts
prefix z is a quiet favorite — it temporarily blows up one pane to full screen so you can focus, then snaps back to your split layout when you press it again.
Resizing panes
Hold the prefix and use the Ctrl- or Alt-arrow keys to resize the current pane:
prefix Ctrl-←/→/↑/↓ # resize by 1 cell (repeat the arrow to keep going)
prefix Alt-←/→/↑/↓ # resize by 5 cells at a time
Want an exact size? Open the command prompt with prefix : and run resize-pane -D 10 (-U up, -D down, -L left, -R right; the number is how many cells). And remember prefix z when you just want one pane full-screen for a moment.
Scrolling and copy mode
By default your mouse wheel may not scroll tmux's history. Enter copy mode with prefix [, then use the arrow keys or PageUp to scroll back through output, and press q to quit copy mode.
Note: To enable mouse support (scroll and click to select panes), add
set -g mouse onto~/.tmux.conf.
Reloading your config
When you tweak ~/.tmux.conf, apply it without restarting: press prefix : to open the command prompt at the bottom, then run source-file ~/.tmux.conf.
A tiny config to start with
Drop this in ~/.tmux.conf for a friendlier setup:
set -g mouse on # mouse scroll + pane selection
set -g history-limit 10000 # remember more scrollback
setw -g mode-keys vi # vi-style movement in copy mode
Wrapping up
That's genuinely most of what you need. The mental model is simple: sessions hold windows, windows hold panes, and everything keeps running whether you're attached or not. Start with tmux new -s work, split a pane with prefix ", detach with prefix d, and reattach with tmux attach — once those four are muscle memory, the rest follows.
Hope this helps! If you want to go deeper, the official wiki below is excellent.