Quick Reference

Cheatsheets

Practical command references for Linux, networking, servers, containers, databases, and more.

Cheatsheet#tmux-cheatsheet

Tmux Cheatsheet

Tmux (Terminal Multiplexer) allows you to run multiple terminal sessions inside a single window. It also keeps processes running in the background even if you disconnect from SSH.

Installation

# Debian/Ubuntu
sudo apt install tmux
 
# Arch Linux
sudo pacman -S tmux
 
# macOS
brew install tmux

Session Management

Run these commands in your regular terminal.

tmux                     # Start a new session
tmux new -s mysession    # Start a new session with name "mysession"
tmux ls                  # List active sessions
tmux a                   # Attach to the last active session
tmux a -t mysession      # Attach to "mysession"
tmux kill-session -t mysession  # Kill "mysession"
tmux kill-server         # Kill all tmux sessions

Prefix Key

Inside Tmux, all shortcuts start with a prefix key. By default, the prefix is Ctrl + b.

Window Management (Tabs)

After pressing Ctrl + b:

  • c : Create a new window
  • w : List all windows and choose one
  • n : Go to next window
  • p : Go to previous window
  • 0 to 9 : Go to a specific window number
  • , : Rename current window
  • & : Kill current window

Pane Management (Splits)

After pressing Ctrl + b:

  • % : Split pane vertically (left/right)
  • " : Split pane horizontally (top/bottom)
  • Arrow Keys : Switch between panes
  • x : Kill current pane
  • z : Toggle pane zoom (fullscreen)
  • Space : Cycle through pane layouts
  • { / } : Swap pane with the next/previous pane

Configuration (~/.tmux.conf)

You can customize the prefix and appearance in ~/.tmux.conf. After changing it, reload with tmux source-file ~/.tmux.conf.

# Change prefix to Ctrl + a (like GNU Screen)
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
 
# Enable mouse support
set -g mouse on