Fundamentals 10 min read

Master Tmux: Essential Commands and Workflow for Terminal Multiplexing

This guide explains what Tmux is, how it separates sessions from windows, and provides step‑by‑step instructions for installing, starting, detaching, attaching, managing sessions, panes, and windows, along with useful shortcut keys and command examples.

ITPUB
ITPUB
ITPUB
Master Tmux: Essential Commands and Workflow for Terminal Multiplexing

What Is Tmux?

Tmux is a terminal multiplexer that lets you detach a session from a window so the session continues running in the background, and later re‑attach it to another window. It enables multiple sessions, window sharing, and flexible pane layouts, offering advantages over GNU Screen.

Session and Process

A typical terminal interaction creates a temporary session tied to a window; closing the window ends the session and its processes. Detaching breaks this link, allowing the session to persist.

Key Features

Access multiple sessions in a single window.

Attach new windows to existing sessions.

Share sessions among users.

Split windows vertically or horizontally.

Basic Usage

Installation

# Ubuntu or Debian
sudo apt-get install tmux

# CentOS or Fedora
sudo yum install tmux

# macOS
brew install tmux

Start and Exit

Run tmux to start a new session. Exit with Ctrl+d or the exit command.

tmux
exit

Prefix Key

The default prefix is Ctrl+b. After pressing the prefix, you can invoke shortcuts such as Ctrl+b ? for help, then press Esc or q to close the help pane.

Session Management

Create a Session

tmux new -s <session-name>

Detach a Session

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

Attach to a Session

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

Kill a Session

# By number
 tmux kill-session -t 0
# By name
 tmux kill-session -t <session-name>

Switch Sessions

tmux switch -t 0
# or by name
 tmux switch -t <session-name>

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

Minimal Workflow

Create a session: tmux new -s my_session.

Run programs inside the Tmux window.

Detach with Ctrl+b d.

Later re‑attach with tmux attach-session -t my_session.

Pane Operations

Split Panes

# Split vertically (top/bottom)
 tmux split-window
# Split horizontally (left/right)
 tmux split-window -h

Move Cursor Between Panes

# Up
 tmux select-pane -U
# Down
 tmux select-pane -D
# Left
 tmux select-pane -L
# Right
 tmux select-pane -R

Swap 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> – move cursor to another pane.

Ctrl+b ; – switch to previous pane.

Ctrl+b o – switch to next pane.

Ctrl+b { / } – move pane left/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> – resize pane.

Ctrl+b q – show pane numbers.

Window Management

Create a New Window

tmux new-window
# With a name
 tmux new-window -n <window-name>

Switch Windows

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

Rename a Window

tmux rename-window <new-name>

Window Shortcuts

Ctrl+b c – create a new window.

Ctrl+b p – go to previous window.

Ctrl+b n – go to next window.

Ctrl+b <number> – switch to window by number.

Ctrl+b w – list windows to select.

Ctrl+b , – rename current 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.

Sessionterminalcommand-linetmuxpane
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

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.