Tmux for Beginners: A Complete Terminal Multiplexer Guide
Tmux is a terminal multiplexer that lets you switch between multiple programs in one terminal, detach sessions and continue running them in the background, and reattach to sessions from different locations. It is an essential tool for developers and system administrators who spend significant time in the terminal.
📑 Table of Contents
Why Use Tmux?
- Persistent Sessions – Survive SSH disconnections
- Window Management – Multiple terminals in one window
- Session Sharing – Pair programming support
- Scriptable – Automate your workspace setup
- Keyboard Driven – Fast navigation without mouse
Installation
# Debian/Ubuntu
sudo apt install tmux
# RHEL/CentOS/Fedora
sudo dnf install tmux
# macOS
brew install tmux
# Arch Linux
sudo pacman -S tmux
Basic Concepts
Tmux uses a hierarchical structure: Sessions contain Windows, and Windows contain Panes. The prefix key (default Ctrl+b) precedes most commands.
Essential Commands
# Start new session
tmux new -s mysession
# Detach from session
Ctrl+b d
# List sessions
tmux ls
# Attach to session
tmux attach -t mysession
# Kill session
tmux kill-session -t mysession
Window Management
# Create new window
Ctrl+b c
# Switch windows
Ctrl+b n # Next window
Ctrl+b p # Previous window
Ctrl+b 0-9 # Window by number
# Rename window
Ctrl+b ,
# Close window
Ctrl+b &
Pane Management
# Split horizontally
Ctrl+b %
# Split vertically
Ctrl+b "
# Navigate panes
Ctrl+b arrow keys
# Resize panes
Ctrl+b Ctrl+arrow keys
# Close pane
Ctrl+b x
# Toggle pane zoom
Ctrl+b z
Recommended Configuration
# ~/.tmux.conf
# Change prefix to Ctrl+a
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# Enable mouse
set -g mouse on
# Start windows at 1
set -g base-index 1
# Better colors
set -g default-terminal "screen-256color"
# Easier splits
bind | split-window -h
bind - split-window -v
# Reload config
bind r source-file ~/.tmux.conf \; display "Reloaded!"
Conclusion
Tmux transforms terminal work by enabling persistent, organized, and efficient workflows. Start with basic session and window management, then explore panes and customization as you become comfortable.
Was this article helpful?
About Ramesh Sundararamaiah
Red Hat Certified Architect
Expert in Linux system administration, DevOps automation, and cloud infrastructure. Specializing in Red Hat Enterprise Linux, CentOS, Ubuntu, Docker, Ansible, and enterprise IT solutions.