Master tmux: Install, Navigate Sessions, Windows, and Panes Like a Pro
This guide explains what tmux is, how to install it on Ubuntu, CentOS, and macOS, and provides detailed instructions for creating, switching, and managing sessions, windows, and panes using essential keyboard shortcuts and commands.
What is tmux?
tmux (Terminal Multiplexer) is a BSD‑licensed tool that lets you run multiple terminal sessions inside a single window, keep programs running after you detach, and share sessions with other users.
Installation
On Ubuntu/Debian: sudo apt-get install tmux On CentOS/RHEL: yum install -y tmux On macOS (using Homebrew): brew install tmux Check the installed version with:
tmux -VStarting tmux
Run tmux to start a new session. The first window contains a single pane that behaves like a normal terminal.
Key Bindings Overview
All shortcuts start with the prefix Ctrl+b. After pressing the prefix, release the keys and then press the indicated key.
Ctrl+b ? – List all shortcuts.
Ctrl+b d – Detach from the current session.
Ctrl+b D – Choose a session to detach when multiple sessions exist.
Ctrl+b c – Create a new window.
Ctrl+b & – Close the current window.
Ctrl+b , – Rename the current window.
Ctrl+b . – Change the window index.
Ctrl+b f – Search text in all windows.
Ctrl+b " – Split the current pane horizontally.
Ctrl+b % – Split the current pane vertically.
Ctrl+b o – Cycle to the next pane.
Ctrl+b q – Show pane numbers for quick jump.
Ctrl+b x – Close the active pane.
Ctrl+b z – Toggle zoom for the active pane.
Ctrl+b t – Show a clock in the status line.
Window Management
Each session can contain multiple windows, identified by an index and a name (e.g., 0:bash). Use the following shortcuts to navigate: Ctrl+b p – Switch to the previous window. Ctrl+b n – Switch to the next window. Ctrl+b 0…9 – Jump directly to a window by its number. Ctrl+b w – List all windows and select one with arrow keys. Ctrl+b l – Switch to the last accessed window.
Pane Management
Within a window you can split the screen into multiple panes. Ctrl+b % – Vertical split (left/right). Ctrl+b " – Horizontal split (top/bottom). Ctrl+b Space – Cycle through preset pane layouts. Ctrl+b Alt+←/→/↑/↓ – Resize pane by 1 cell. Ctrl+b Alt+←/→/↑/↓ (with larger step) – Resize by 5 cells.
Session Management
List all running tmux sessions with tmux ls. The output shows session name, number of windows, and creation time.
tmux lsConclusion
Understanding tmux’s three core concepts—sessions, windows, and panes—allows you to keep long‑running tasks alive, collaborate in real time, and organize workspaces efficiently. Advanced users can customize key bindings, enable mouse support, and tweak the status line to further boost productivity.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
