Fundamentals 10 min read

Master Terminal Sessions with Tmux: A Complete Beginner’s Guide

This article introduces Tmux, a powerful terminal multiplexer, explains its core concepts such as sessions, windows, and panes, and provides step‑by‑step commands for installation, basic usage, session management, pane manipulation, and window control, enabling developers to work more efficiently in the command line.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Terminal Sessions with Tmux: A Complete Beginner’s Guide

What is tmux?

tmux is a terminal multiplexer that separates the lifecycle of a session from the terminal window. A session continues to run its processes even after the window is closed, and can be re‑attached later from any terminal. It also enables multiple sessions in a single window, sharing sessions among users, and splitting windows into vertical or horizontal panes.

Installation

# Ubuntu / Debian
sudo apt-get install tmux

# CentOS / Fedora
sudo yum install tmux

# macOS (Homebrew)
brew install tmux

Starting and exiting

Start a new session with tmux. The status line shows the current window on the left and system information on the right. Exit a tmux session by typing exit or pressing Ctrl+d inside the tmux window.

Prefix key

All tmux shortcuts are invoked after the prefix key Ctrl+b. For example, Ctrl+b ? displays a help pane; press Esc or q to close it.

Session management

Creating a session

tmux new -s <session-name>

Detaching a session

Press Ctrl+b d or run tmux detach. The session keeps running in the background.

Listing sessions

tmux ls          # or
tmux list-sessions

Attaching to a session

# By session number
 tmux attach -t 0

# By session name
 tmux attach -t <session-name>

Killing a session

tmux kill-session -t 0
# or
 tmux kill-session -t <session-name>

Renaming a session

tmux rename-session -t 0 <new-name>

Session shortcuts

Ctrl+b d – detach current session

Ctrl+b s – list all sessions

Ctrl+b $ – rename current session

Pane operations

Splitting panes

# Split vertically (default)
tmux split-window

# Split horizontally
 tmux split-window -h
tmux pane layout
tmux pane layout

Selecting panes

# Move focus up
 tmux select-pane -U
# Move focus down
 tmux select-pane -D
# Move focus left
 tmux select-pane -L
# Move focus right
 tmux select-pane -R

Swapping panes

# Move current pane up
 tmux swap-pane -U
# Move current pane down
 tmux swap-pane -D

Pane shortcuts

Ctrl+b % – split vertically

Ctrl+b " – split horizontally

Ctrl+b <arrow key> – move focus to another pane

Ctrl+b ; – switch to previous pane

Ctrl+b o – switch to next pane

Ctrl+b { – move pane left

Ctrl+b } – move pane right

Ctrl+b Ctrl+o – move pane up

Ctrl+b Alt+o – move pane down

Ctrl+b x – close pane

Ctrl+b ! – break pane into a new window

Ctrl+b z – toggle pane fullscreen

Ctrl+b Ctrl+<arrow key> – resize pane

Ctrl+b q – show pane numbers

Window management

Creating windows

# New window
 tmux new-window
# New window with a name
 tmux new-window -n <window-name>

Selecting windows

# By number
 tmux select-window -t <window-number>
# By name
 tmux select-window -t <window-name>

Renaming windows

tmux rename-window <new-name>

Window shortcuts

Ctrl+b c – create new window

Ctrl+b p – go to previous window

Ctrl+b n – go to next window

Ctrl+b <number> – switch to specific window

Ctrl+b w – list windows for selection

Ctrl+b , – rename window

Other useful commands

# List all key bindings
 tmux list-keys

# List all commands and options
 tmux list-commands

# Show session information
 tmux info

# Reload configuration file
 tmux source-file ~/.tmux.conf
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Command-lineSession Managementterminal multiplexertmuxpane
Liangxu Linux
Written by

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.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.