You want to start using tmux but find the commands overwhelming, the key bindings cryptic, and the learning curve steep.
This tutorial teaches tmux through hands-on practice. By the end, you’ll create sessions, split panes, and manage multiple terminal windows confidently.
If you’re new to tmux, start with What Is Tmux? to understand what it does and why it matters.
Prerequisites
Before starting, you need:
- A terminal emulator installed (such as Terminal on macOS, GNOME Terminal on Linux, or Windows Terminal with WSL on Windows).
- Basic command-line familiarity (navigating directories, running commands).
- tmux installed (see the installation section).
Installing Tmux
Install tmux for your operating system.
macOS
Use Homebrew:
brew install tmuxVerify installation:
tmux -VLinux
Most distributions include tmux in their repositories.
Ubuntu/Debian:
sudo apt update
sudo apt install tmuxFedora/RHEL:
sudo dnf install tmuxArch Linux:
sudo pacman -S tmuxWindows
tmux requires Linux; on Windows, use Windows Subsystem for Linux (WSL). WSL provides a Linux environment within Windows, letting you run tmux as you would on a Linux server.
Prerequisites:
- Install WSL. See the Microsoft WSL documentation for instructions.
- Open your WSL terminal (Ubuntu, Debian, or your preferred Linux distribution).
Installation:
Once WSL is set up, install tmux using your Linux distribution’s package manager:
Ubuntu/Debian in WSL:
sudo apt update
sudo apt install tmuxFedora/RHEL in WSL:
sudo dnf install tmuxVerify installation:
tmux -VCreating Your First Session
Start a new tmux session:
tmuxThis creates an unnamed session and attaches you to it. A status bar at the bottom shows session information.
Create a named session:
tmux new -s mysessionReplace mysession with your preferred name. Named sessions help organize multiple projects.
To exit tmux, type exit in the last pane or window (or press Ctrl-d). The session ends when the last window closes.
Understanding Tmux Basics
Now that you’ve started your first tmux session, learn how keybindings work.
tmux uses a prefix key to trigger commands. The default prefix is Ctrl-b. Press Ctrl-b, release both keys, then press the command key.
Think of Ctrl-b as telling tmux, “the next key is a tmux command.”
tmux’s structure works like this: one server manages multiple sessions; each session holds multiple windows; each window holds multiple panes.
Essential Session Commands
Detaching from a Session
Detach without ending the session:
- Press
Ctrl-b. - Release both keys.
- Press
d.
Your session keeps running in the background. Even if you close your terminal window, the session persists.
Listing Sessions
List all active sessions from the command line:
tmux lsOutput looks like:
mysession: 1 windows (created Sun Nov 24 10:30:00 2025)
another: 1 windows (created Sun Nov 24 11:00:00 2025)From inside a tmux session, open the interactive session list:
- Press
Ctrl-b. - Press
s.
Navigate with the arrow keys and press Enter to switch to the selected session.
Switching Between Sessions
Cycle between sessions without opening the interactive list:
- Next session:
Ctrl-bthen). - Previous session:
Ctrl-bthen(.
Attaching to a Session
Attach to an existing session:
tmux attach -t mysessionReplace mysession with your session name. Use tmux a -t mysession as a shorter alias.
Killing a Session
End a session permanently:
tmux kill-session -t mysessionOr from inside tmux:
- Press
Ctrl-b. - Press
&. - Confirm with
y.
Working with tmux Windows
tmux windows work like browser tabs within a session. Each window holds multiple panes.
Creating a New Window
Create a new window:
- Press
Ctrl-b. - Press
c.
The status bar shows window numbers: 0:bash, 1:bash, etc.
Switching Between Windows
Navigate windows:
- Next window:
Ctrl-bthenn. - Previous window:
Ctrl-bthenp. - Specific window:
Ctrl-bthen the window number (e.g.,Ctrl-bthen0for window 0).
Renaming a Window
Rename the current window:
- Press
Ctrl-b. - Press
,. - Type the new name.
- Press Enter.
Closing a Window
Close the current window:
- Press
Ctrl-b. - Press
&. - Confirm with
y.
Or type exit in the terminal.
Splitting Panes
Panes split a single window into multiple terminals. The diagram below shows one window with a top row split into two panes and a full-width bottom pane:
┌─────────────────┬─────────────────┐
│ │ │
│ Top Pane │ Top Right │
│ │ │
├─────────────────┴─────────────────┤
│ │
│ Bottom Pane │
│ │
└───────────────────────────────────┘Creating Horizontal Panes
Split the window horizontally (top and bottom):
- Press
Ctrl-b. - Press
".
Two panes appear stacked vertically.
Creating Vertical Panes
Split the window vertically (left and right):
- Press
Ctrl-b. - Press
%.
Two panes appear side-by-side.
Navigating Between Panes
Switch between panes:
- Next pane:
Ctrl-btheno. - Previous pane:
Ctrl-bthen;. - Directional navigation:
Ctrl-bthen arrow keys (←,→,↑,↓).
Resizing Panes
Resize the current pane using Ctrl-b then Ctrl-←/→/↑/↓:
Ctrl-bthenCtrl-←to shrink left.Ctrl-bthenCtrl-→to expand right.Ctrl-bthenCtrl-↑to expand up.Ctrl-bthenCtrl-↓to shrink down.
Closing Panes
Close the current pane:
Type exit in the pane’s terminal, or:
- Press
Ctrl-b. - Press
x. - Confirm with
y.
Common Workflows
Remote Server Development
Connect to a remote server and start a session:
ssh user@server
tmux new -s devIf your SSH connection drops, the tmux session keeps running on the server. Reconnect and reattach to pick up where you left off:
ssh user@server
tmux attach -t devMulti-Pane Development Setup
Create a three-pane setup to monitor logs, run tests, and execute commands:
- Start tmux:
tmux new -s project. - Split horizontally:
Ctrl-bthen". - Move to the bottom pane:
Ctrl-btheno. - Split the bottom pane vertically:
Ctrl-bthen%. - Navigate panes:
Ctrl-bthen arrow keys.
This navigation pattern (Ctrl-b then arrow keys) works in any tmux window.
You now have three panes:
- Top: Main terminal.
- Bottom-left: Logs or tests.
- Bottom-right: Commands or database queries.
Project Organization
Create separate sessions for different projects:
tmux new -s frontend
tmux new -s backend
tmux new -s deploymentSwitch between projects:
tmux attach -t frontend
# Work on frontend
# Detach with Ctrl-b d
tmux attach -t backend
# Work on backendLong-Running Processes
Start a long-running process in tmux:
tmux new -s migration
# Run your long command
./long-running-script.sh
# Detach with Ctrl-b dCheck progress later:
tmux attach -t migrationYou’ve now practiced the most common tmux workflows: remote development, multi-pane layouts, project separation, and long-running tasks.
Copy Mode
Copy mode lets you scroll through terminal history and copy text within tmux.
Entering Copy Mode
Enter copy mode:
- Press
Ctrl-b. - Press
[.
You are now in copy mode. Navigate with arrow keys; if your tmux uses vi-style keys, use h, j, k, l. Otherwise, use arrow keys or enable vi mode in your config.
Copying Text
- Navigate to the start of the text you want to copy.
- Press
Spaceto start selection. - Move to the end of the text.
- Press
Enterto copy.
If Space and Enter behave differently, your tmux config or Linux distro uses different copy-mode bindings. Some distros ship custom defaults, or your dotfiles redefine keys. Check ~/.tmux.conf or the tmux manual for your key mappings.
Pasting Text
Paste copied text:
- Press
Ctrl-b. - Press
].
Basic Configuration
This section is optional. If you’re new to tmux, skip it and return when you’re comfortable with the default keys. Configuration pays off most when you switch windows and panes often or use tmux all day.
Create a configuration file to customize tmux:
touch ~/.tmux.confAdd common customizations:
# Set prefix to Ctrl-a (easier to reach)
# Changing the prefix to Ctrl-a keeps your hands on the home row, which many terminal users prefer
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Enable mouse support
set -g mouse on
# Start windows and panes at 1, not 0
# Starting windows and panes at 1 instead of 0 feels more natural to many users when switching by number
set -g base-index 1
setw -g pane-base-index 1
# Reload config file
bind r source-file ~/.tmux.conf \; display "Config reloaded!"Reload your configuration:
- Press your tmux prefix (
Ctrl-bby default, orCtrl-aif you changed it above). - Press
:to enter command mode. - Type
source-file ~/.tmux.conf. - Press Enter.
Or restart tmux to apply changes.
Troubleshooting Common Issues
Can’t Detach from Session
If Ctrl-b d doesn’t work:
- Ensure you press
Ctrl-b, release both keys, then pressd. - Check if another program is intercepting
Ctrl-b. - Try
Ctrl-bthen:to enter command mode, then typedetach.
Session Not Persisting
Sessions persist by default. If they end unexpectedly:
Check for accidental session kills:
- Verify you’re not pressing
Ctrl-bthen&, which kills the current window. - Verify you’re not typing
exitin the terminal, which closes the session.
Verify tmux server status:
tmux lsExpected output shows active sessions:
dev: 1 windows (created Sun Nov 24 10:30:00 2025)
project: 2 windows (created Sun Nov 24 11:00:00 2025)tmux runs a background server that holds sessions and windows. tmux ls queries this server for active sessions.
When no server is running, you see:
failed to connect to serverThis message means tmux has no running sessions. Create a new one with tmux new -s dev.
Check for tmux errors:
On Linux and macOS, tmux runs as a user process, not a system service. Check your terminal history for shell errors or crashes. If tmux crashes repeatedly, note the error message and search the tmux GitHub issues or documentation.
For example, you might see tmux: server exited unexpectedly in your terminal. Try starting a new session with tmux new -s test. If it fails again with the same error, search for or report it on the tmux GitHub issues.
If you suspect your tmux config causes the crash, start with a minimal config:
tmux -f /dev/null new -s testIf this works but tmux new -s test fails, the problem is in your ~/.tmux.conf.
Panes Not Resizing
If panes do not resize:
Verify the key sequence:
- Ensure you’re using
Ctrl-bthen theCtrl-←/→/↑/↓keys, just like in the pane resizing section above. - Try releasing
Ctrl-bcompletely before pressingCtrl-arrow.
Use command mode as an alternative:
If key bindings fail, use command mode:
- Press
Ctrl-bthen:to enter command mode. - Type
resize-pane -L 5(shrink left by 5 characters). - Adjust direction:
-L(left),-R(right),-U(up),-D(down). - Adjust size: Change
5to your desired number of characters.
Check terminal emulator conflicts:
Some terminal emulators intercept Ctrl-arrow keys. Check your terminal’s key bindings for conflicts and disable them.
Can’t See Status Bar
The status bar appears at the bottom of the terminal. If missing:
- Check your configuration file for
set -g status on. - Verify you’re actually in a tmux session (look for
[mysession]in the status bar).
Next Steps
Now that you know tmux basics, explore next:
- Customize your configuration: Create a
.tmux.confthat matches your workflow. - Learn advanced features: Scripting, session sharing, and plugins.
- Practice daily: Use tmux for real work to build muscle memory.
- Read the full tmux manual (man page):
man tmuxcovers all features and options.
For task recipes, see the tmux how-to guides when available. For complete command listings, consult the tmux manual. This tutorial covers core workflows; use it alongside the manual.
tmux grows more powerful with regular use. Start with simple sessions, then add panes and windows as needed.
Quick Reference
Use this quick reference while practicing the steps above. These tables support the tutorial; they do not replace the tmux manual.
These shortcuts assume the default prefix Ctrl-b. If you changed your prefix (for example, to Ctrl-a in your ~/.tmux.conf), substitute your prefix key wherever you see Ctrl-b.
Session Commands
- tmux new -s name - Create a new named session
- tmux ls - List all active sessions
- tmux attach -t name - Attach to an existing session
- tmux kill-session -t name - End a session permanently
- Ctrl-b d - Detach from the current session
- Ctrl-b s - Open the interactive session list
- Ctrl-b ) - Switch to the next session
- Ctrl-b ( - Switch to the previous session
Window Commands
- Ctrl-b c - Create a new window
- Ctrl-b n - Move to the next window
- Ctrl-b p - Move to the previous window
- Ctrl-b 0-9 - Switch to a specific window by number
- Ctrl-b , - Rename the current window
- Ctrl-b & - Close the current window
Pane Commands
- Ctrl-b “ - Split the window horizontally
- Ctrl-b % - Split the window vertically
- Ctrl-b o - Move to the next pane
- Ctrl-b ; - Move to the previous pane
- Ctrl-b arrow keys - Navigate panes directionally
- Ctrl-b Ctrl-arrow keys - Resize the current pane
- Ctrl-b x - Close the current pane
Copy Mode Commands
- Ctrl-b [ - Enter copy mode
- Space - Start text selection
- Enter - Copy the selection
- Ctrl-b ] - Paste copied text
References
- tmux Official Website - Main website with features, documentation, and download information
- tmux Manual Page - Comprehensive command reference and configuration guide
- tmux GitHub Repository - Open-source codebase and community contributions
- What Is Tmux? - Explanation of what tmux is and why it matters
Commands in this tutorial were verified with tmux 3.x. Run tmux -V to check your version.
If something in this tutorial doesn’t work as described, let me know so I can fix it.

Comments #