TMUX on Terminal: Install, Setup & Practical Guide Complete Beginner to Pro Guide

TMUX lets you split one terminal window into many shells, detach from them, and pick them up again later, even after an SSH connection drops. If you work in a terminal every day for development, server management or DevOps, it is one of the highest-return tools you can learn in an afternoon.
This guide takes you from zero to confident use. You will install TMUX on every major platform, learn sessions, windows and panes, build a practical ~/.tmux.conf, add plugins that restore your work after a reboot, and walk through real workflows such as long-running jobs over SSH and a one-command development layout. It ends with a cheat sheet, troubleshooting steps, common mistakes and a FAQ.
TL;DR: Get Started in 60 Seconds
If you only have a minute, these five commands cover the core idea of TMUX:
tmux new -s work # start a named session called "work"
# press Ctrl+b then % to split the screen into two panes
# press Ctrl+b then d to detach (everything keeps running)
tmux ls # list running sessions
tmux attach -t work # come back exactly where you left offThe rest of this guide explains each step, why it works, and how to make TMUX fit the way you work.
What Is TMUX?
TMUX (short for Terminal Multiplexer) is a command-line program that runs several terminal sessions inside a single window and keeps them alive in the background. It is open source, written in C, and available on Linux, macOS, BSD and Windows (through WSL).
The key idea is its client-server design. When you run tmux, it starts a background server that owns your shells, and your terminal window becomes a client attached to that server. Close the window or lose the SSH connection and only the client disappears. The server, and every program running inside it, keeps going.
The Three Layers: Sessions, Windows and Panes
TMUX organizes everything into three nested layers. Understanding them makes every command easier to remember.
Server
└── Session (a workspace, e.g. "backend")
├── Window 1 (like a browser tab, e.g. "editor")
│ ├── Pane A (a shell)
│ └── Pane B (another shell)
└── Window 2 (e.g. "logs")
└── Pane ALayer | What it is | Typical use |
|---|---|---|
Session | A complete workspace that you can detach from and reattach to | One per project or server |
Window | A full-screen tab inside a session | Separate tasks such as editor, server, logs |
Pane | A split section of a window running its own shell | Watching logs next to a running command |
Who uses it: developers, sysadmins, DevOps and backend engineers, data scientists running long training jobs, and anyone who works on remote Linux servers over SSH.
Why Use TMUX?
TMUX solves a handful of everyday terminal problems that tabs and a plain SSH session cannot. Here are the situations where it pays off most.
Your SSH connection drops. Without TMUX, the running command dies with the connection. With TMUX, it keeps running and you reattach when you are back.
You run long jobs. Database migrations, backups, builds, model training and large file transfers can run for hours. Start them in TMUX, detach, and check later.
You juggle several services. Run an app server, a database shell and a log tail side by side in one screen instead of juggling windows.
You work on many projects. Keep one named session per project and switch between them in a second.
You pair program or teach. Two people can attach to the same session and watch the same terminal live.
You want a repeatable environment. A short script can rebuild your exact layout every morning.
It is also very light on resources. A typical session uses only a few megabytes of memory, which is why it is safe to leave running on small servers.
How to Install TMUX
TMUX is in the default package repositories of almost every Linux distribution and macOS, so installation is a single command. Pick your platform below.
Ubuntu and Debian (including WSL)
sudo apt update
sudo apt install tmuxCentOS, RHEL, Rocky Linux and AlmaLinux
sudo dnf install tmux # RHEL/CentOS 8 and newer
sudo yum install tmux # older releasesFedora
sudo dnf install tmuxArch Linux
sudo pacman -S tmuxAlpine Linux
sudo apk add tmuxmacOS (Homebrew)
brew install tmuxWindows
TMUX does not run natively in Windows PowerShell or Command Prompt. Install Windows Subsystem for Linux (WSL), open an Ubuntu shell, and use the Ubuntu commands above.
Build from Source (Latest Version)
Distribution packages are sometimes a few releases behind. If you need a newer version, build it yourself. You need libevent, ncurses, a C compiler, make and autoconf installed first.
git clone https://github.com/tmux/tmux.git
cd tmux
sh autogen.sh
./configure
make
sudo make installVerify the Installation
tmux -VIf TMUX is installed correctly you will see a version number such as tmux 3.4. Some options used later in this guide need version 3.2 or newer, and the guide marks them when that applies.
Your First TMUX Session
Type tmux and press Enter to start. You land in a new session with one window and one pane, and a green status bar appears at the bottom showing the session name, window list and clock.
The Prefix Key
Nearly every TMUX shortcut starts with the prefix key, which is Ctrl + b by default. Press and release the prefix, then press the next key. For example, Ctrl + b then c creates a new window. It is a two-step sequence, not a chord where you everything together.
To see every key binding at any time, press Ctrl + b then ?. Press q to close the list.
A 2-Minute Walkthrough
Run
tmux new -s practiceto start a named session.Press
Ctrl + bthen%to split the window into left and right panes.Press
Ctrl + bthen the right or left arrow key to move between panes.Press
Ctrl + bthencto open a second window. The status bar now lists windows0and1.Press
Ctrl + bthendto detach. You are back in your normal shell.Run
tmux attach -t practice. Your panes and windows are exactly as you left them.
That loop of start, split, detach and reattach is 80% of daily TMUX use.
Managing Sessions
Sessions are what make TMUX persistent, so learn these commands first. Always give sessions names so you can tell them apart.
Task | Command or keys |
|---|---|
Create a named session |
|
Create a session in the background |
|
List sessions |
|
Attach to a session |
|
Attach to the most recent session |
|
Detach from the current session |
|
Switch between sessions |
|
Rename the current session |
|
Kill one session |
|
Kill every session and the server |
|
A handy shortcut is tmux new -A -s main. It attaches to the session named main if it exists and creates it if not, so you can use one command every time.
When you detach, your session keeps running in the background. Programs inside it continue to execute, and output keeps scrolling into the session history until you return.
Working with Windows and Panes
Windows act like tabs and panes split a single window, and together they let you build any layout you need.
Windows
Task | Keys |
|---|---|
Create a new window |
|
Next window |
|
Previous window |
|
Jump to window by number |
|
Choose from a list of windows |
|
Rename the current window |
|
Close the current window |
|
Panes
TMUX names its splits from the direction of the dividing line, which confuses many beginners. The % key puts a vertical line down the middle, giving you left and right panes. The " key puts a horizontal line across, giving you top and bottom panes.
Task | Keys |
|---|---|
Split into left and right panes |
|
Split into top and bottom panes |
|
Move to another pane |
|
Cycle to the next pane |
|
Show pane numbers, then jump |
|
Resize a pane | Press |
Zoom a pane to full screen and back |
|
Swap panes |
|
Cycle through preset layouts |
|
Turn a pane into its own window |
|
Close the current pane |
|
The zoom shortcut, Ctrl + b then z, is worth memorizing. It temporarily maximizes the active pane so you can read a long log, then restores the layout when you press it again.
If resizing with the arrow keys is awkward on your keyboard or terminal, the custom bindings in the configuration section below give you a simpler way.
Scrolling, Searching and Copying Text (Copy Mode)
You cannot scroll a TMUX pane with your normal terminal scrollbar, because TMUX keeps its own scrollback buffer. To scroll, enter copy mode with Ctrl + b then [. Move with the arrow keys, Page Up and Page Down, and press q to leave.
If you enable the mouse (see the next section), you can also scroll with the mouse wheel, which switches into copy mode automatically.
Vi-Style Keys in Copy Mode
Add set -g mode-keys vi to your config to use vi keys inside copy mode.
Action | Key (vi mode) |
|---|---|
Start selection |
|
Copy selection and exit |
|
Search forward |
|
Search backward |
|
Next or previous match |
|
Jump to top or bottom |
|
Quit copy mode |
|
After copying, press Ctrl + b then ] to paste the text into any pane. This uses TMUX's own buffer. To send text to your system clipboard, see the clipboard settings in the configuration section.
Tip: If you enabled the mouse and want to select text with your terminal's own selection, hold Shift (or Option on some macOS terminals) while dragging.
How to Customize TMUX with .tmux.conf
TMUX reads its settings from ~/.tmux.conf when the server starts, and a few well-chosen lines make it far more comfortable. Create the file (or open it if it exists) and start with the configuration below.
A Practical Starter Configuration
# ---------- General ----------
set -g mouse on # click panes, resize, scroll with the wheel
set -g history-limit 50000 # keep more scrollback
set -sg escape-time 10 # remove the delay after pressing Esc (helps Vim)
set -g base-index 1 # number windows from 1, not 0
setw -g pane-base-index 1 # number panes from 1 as well
set -g renumber-windows on # close the gap when a window is closed
set -g mode-keys vi # vi keys in copy mode
set -g set-clipboard on # let tmux talk to the system clipboard (terminal permitting)
# ---------- Colors ----------
set -g default-terminal 'tmux-256color'
set -as terminal-features ',xterm-256color:RGB' # true color (tmux 3.2+)
# ---------- Easier splits (new panes open in the current folder) ----------
bind | split-window -h -c '#{pane_current_path}'
bind - split-window -v -c '#{pane_current_path}'
unbind %
unbind '"'
bind c new-window -c '#{pane_current_path}'
# ---------- Vim-style pane navigation ----------
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# ---------- Resize panes with Shift + Prefix ----------
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# ---------- Reload config with Prefix + r ----------
bind r source-file ~/.tmux.conf \; display-message 'Config reloaded!'
# ---------- Status bar ----------
set -g status-interval 5
set -g status-style 'bg=colour235,fg=colour250'
set -g status-left '#[bold] #S '
set -g status-right '%H:%M %d-%b-%Y '
set -g window-status-current-style 'bold,fg=colour39'What the Key Lines Do
mouse onlets you click to select panes and windows, drag borders to resize, and scroll with the wheel. It is the single best setting for beginners.history-limitcontrols how many lines of output each pane remembers. The default of 2000 is small for build logs.escape-timeis the delay TMUX waits afterEscto see whether it begins a longer sequence. The default of 500 ms makes Vim feel sluggish.base-index 1makes window numbers match the key positions on your keyboard, soCtrl + bthen1jumps to the first window.bind |andbind -give you memorable split keys. The-c '#{pane_current_path}'part opens the new pane in the directory you are already in.bind -rmakes a binding repeatable, so you can pressHseveral times after one prefix.
Apply Your Changes
Reload the file inside TMUX with Ctrl + b then r (the binding above), or run this from any shell:
tmux source-file ~/.tmux.confSome settings only take effect when the server starts. If a change does not appear, save your work and run tmux kill-server, then start TMUX again.
Optional: Change the Prefix to Ctrl + a
Many people find Ctrl + a easier to reach than Ctrl + b. Add this block if you prefer it:
unbind C-b
set -g prefix C-a
bind C-a send-prefixNote that Ctrl + a normally jumps to the start of the line in a shell, so bind C-a send-prefix lets you still do that by pressing Ctrl + a twice.
Optional: Copy to the System Clipboard
Add the line that matches your system so that pressing y in copy mode copies to your clipboard:
# macOS
bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'pbcopy'
# Linux with X11
bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'xclip -selection clipboard -in'
# Linux with Wayland
bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'wl-copy'TMUX Plugins with TPM (Tmux Plugin Manager)
Plugins add features such as saving your layout across reboots, and TPM installs them for you. This matters because TMUX sessions live in memory: a server reboot ends every session unless you save them.
Step 1: Install TPM
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpmStep 2: Add Plugins to ~/.tmux.conf
Put this at the very bottom of your config file:
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @continuum-restore 'on' # restore the last saved environment on start
run '~/.tmux/plugins/tpm/tpm' # keep this as the last lineStep 3: Install the Plugins
Reload the config, then press Ctrl + b then Shift + i (capital I). TPM downloads each plugin and shows a confirmation when it finishes.
Plugins Worth Knowing
Plugin | What it does |
|---|---|
| A set of sane defaults that most people agree on |
| Saves and restores sessions, windows, panes and working directories. Save with |
| Saves your environment automatically every 15 minutes and can restore it when TMUX starts |
| Copies selected text to the system clipboard |
Restoring recreates your windows, panes and the directories they were in, and it can relaunch a short list of common programs. It does not bring back the exact state of a running process, so a half-finished job still needs to be restarted.
Practical TMUX Examples
These four workflows show how TMUX is used in real work. Each one is something you can copy and run today.
Example 1: Run a Long Job over SSH Safely
This is the classic reason to use TMUX. A dropped connection no longer kills your task.
ssh user@server
tmux new -s backup
rsync -avh /data/ /mnt/backup/ # or a build, migration or training run
# press Ctrl + b then d to detach, then log out if you like
# later, from any machine:
ssh user@server
tmux attach -t backupThe job kept running the whole time, and you see all the output that appeared while you were away.
Example 2: A One-Command Development Layout
Save this script as dev.sh, make it executable with chmod +x dev.sh, and run it. It rebuilds the same workspace every time, or reattaches if it already exists.
#!/usr/bin/env bash
SESSION="dev"
PROJECT="$HOME/projects/myapp"
# Reattach if the session already exists
tmux has-session -t "$SESSION" 2>/dev/null && exec tmux attach -t "$SESSION"
# Window 1: editor
tmux new-session -d -s "$SESSION" -n editor -c "$PROJECT"
tmux send-keys -t "$SESSION:editor" 'nvim .' C-m
# Window 2: app server and a shell side by side
tmux new-window -t "$SESSION" -n server -c "$PROJECT"
tmux send-keys -t "$SESSION:server" 'npm run dev' C-m
tmux split-window -h -t "$SESSION:server" -c "$PROJECT"
# Window 3: logs and system monitor
tmux new-window -t "$SESSION" -n logs -c "$PROJECT"
tmux send-keys -t "$SESSION:logs" 'tail -f app.log' C-m
tmux split-window -v -t "$SESSION:logs"
tmux send-keys -t "$SESSION:logs" 'htop' C-m
tmux select-window -t "$SESSION:editor"
exec tmux attach -t "$SESSION"Change the project path and commands to suit your stack. The same idea works for a Python virtual environment, a Docker Compose stack or a Rails app.
Example 3: A Quick Server Monitoring Dashboard
Open one window and split it into several panes, then start a different monitor in each:
htopfor CPU and memorywatch -n 5 df -hfor disk spacejournalctl -ffor live system logstail -f /var/log/nginx/error.logfor web server errors
Press Ctrl + b then z to zoom into whichever pane needs a closer look, and press it again to return to the dashboard.
Example 4: Pair Programming and Teaching
Two people logged into the same machine as the same user can share one terminal. Person A runs tmux new -s pair. Person B connects over SSH and runs tmux attach -t pair. Both see and control the same screen in real time.
To let someone watch without typing, attach in read-only mode with tmux attach -t pair -r.
Only share sessions with people you trust. A shared TMUX session gives the other person full control of your shell, including anything your user account can do.
TMUX Cheat Sheet
Bookmark this table. Every key below is pressed after the prefix (Ctrl + b by default) unless the Command column shows a shell command.
Keys Pressed After the Prefix
Area | Keys | What it does |
|---|---|---|
Session |
| Detach from the session |
Session |
| Choose a session from a list |
Session |
| Rename the session |
Window |
| Create a window |
Window |
| Next / previous window |
Window |
| Jump to a window by number |
Window |
| Rename the window |
Window |
| Close the window |
Pane |
| Split into left and right panes |
Pane |
| Split into top and bottom panes |
Pane | Arrow keys | Move between panes |
Pane |
| Zoom or unzoom the pane |
Pane |
| Close the pane |
Pane |
| Cycle through layouts |
Mode |
| Enter copy mode (scroll and select) |
Mode |
| Paste the copied text |
Mode |
| Open the TMUX command prompt |
Help |
| List all key bindings |
Help |
| Show a clock in the pane |
Shell Commands
Command | What it does |
|---|---|
| Start a named session |
| Attach to the session, or create it if missing |
| List sessions |
| Attach to a session |
| Attach in read-only mode |
| Rename a session |
| Kill one session |
| Kill the server and all sessions |
| Type a command into a pane and press Enter |
| Print the visible text of a pane |
| Reload your configuration |
| Print every key binding |
The send-keys command is what makes TMUX scriptable, and it is how the development layout script in the examples section works.
Troubleshooting Common TMUX Problems
Most TMUX problems fall into a handful of patterns. Find your symptom in the table, then read the fix below it.
Symptom | Likely cause | Quick fix |
|---|---|---|
| No session is running | Start one with |
| You ran | Detach first, or use |
| A session with that name exists | Attach with |
| The | Set |
Colors look wrong or washed out |
| Add |
Vim feels slow after pressing Esc | High | Add |
Config changes do not apply | The config was not reloaded | Run |
Mouse scroll does nothing | Mouse mode is off | Add |
Cannot select text with the mouse | TMUX is capturing the mouse | Hold |
Sessions disappeared after a reboot | Sessions live in memory | Use |
Using TMUX Inside TMUX (Nested Sessions)
If you SSH from a local TMUX session into a server that also runs TMUX, your prefix keys go to the outer session. To send a command to the inner session, press the prefix twice. For example, Ctrl + b Ctrl + b then c opens a window in the inner session. Many people avoid the confusion by running TMUX only on the remote machine.
Check Your Version
When an option is rejected with unknown option or invalid option, your TMUX is probably older than the guide you are following. Run tmux -V, then upgrade through your package manager or build from source.
Common TMUX Mistakes (and How to Avoid Them)
Forgetting the prefix key. Beginners often press
cor%on its own. Always pressCtrl + bfirst, release it, then press the command key.Typing
exitwhen you meant to detach.exitcloses the pane, and closing the last pane ends the session and the programs in it. UseCtrl + bthendto leave a job running.Not naming sessions. A plain
tmuxcreates sessions called0,1,2, which are hard to tell apart. Usetmux new -s project-name.Running
kill-servercasually. It ends every session and every program inside them. Preferkill-session -t nameunless you really want a clean slate.Starting TMUX inside TMUX. This leads to the nested-session error and confusing key presses. Check with
echo $TMUXbefore starting a new one.Expecting sessions to survive a reboot. They live in memory. Use
tmux-resurrectandtmux-continuumif you need that.Editing the config and not reloading it. Changes apply only after
source-file, or after the server restarts for some options.Staying on the defaults. The default setup is minimal. Mouse support, sensible splits and a readable status bar make the first week much more pleasant.
Best Practices
Keep one session per project and name it after the project.
Name windows by task, such as
editor,serverandlogs.Put your
~/.tmux.confin version control so your setup follows you from machine to machine.Use a script (like the one above) for any layout you rebuild more than twice.
Learn a few shortcuts well, such as detach, split, zoom and copy mode, before collecting dozens.
Remember that
nohupanddisowncan also keep a single command alive, but they cannot give you an interactive terminal to return to the way TMUX does.
Benefits of Using TMUX
Session persistence. Your processes keep running after you log out or lose your connection.
Fewer windows to juggle. Panes and windows keep related shells together in one terminal.
A better SSH workflow. Remote work becomes safe, because a flaky network no longer costs you work.
Lightweight and fast. It uses very little memory and works over slow connections.
Repeatable and scriptable. A short script recreates your whole workspace on demand.
Works everywhere. The same keys behave the same on a laptop, a cloud server and a Raspberry Pi.
TMUX vs GNU Screen
GNU Screen is the older terminal multiplexer and is still available on many systems. Both tools keep sessions alive after you disconnect. TMUX is generally preferred for new setups because of its cleaner configuration and scripting.
Feature | TMUX | GNU Screen |
|---|---|---|
Persistent, detachable sessions | Yes | Yes |
Split panes | Yes, easy to arrange and resize | Yes, more limited |
Configuration and scripting | Consistent commands, easy to script | Older, less consistent syntax |
Mouse support | Built in | Limited |
Status bar customization | Extensive | Basic |
Plugin ecosystem | Large (TPM) | Small |
Serial device connections | No | Yes ( |
Often preinstalled | Sometimes | Sometimes, on older systems |
Choose TMUX unless you need Screen's built-in serial terminal or are stuck on a machine where only Screen is installed.
Conclusion
TMUX turns a single terminal into a persistent, organized workspace that survives disconnects, and it takes only a few minutes to start getting value from it. Its three layers, sessions, windows and panes, cover almost every workflow you will meet on local machines and remote servers.
Here is a sensible path to follow:
Install TMUX and practice the start, split, detach and reattach loop for a few days.
Add the starter configuration so the mouse, splits and status bar work the way you expect.
Install TPM with
tmux-resurrectandtmux-continuumso reboots stop costing you your layout.Write a small script for the workspace you rebuild most often.
If you work on Linux servers or remote machines regularly, a week of daily use is usually enough to make TMUX a habit you will not want to give up.
Was this article helpful?



Comments
Leave a comment
Loading comments...