tmux Cheatsheet for DevOps and Cloud Engineers (2025)

🧰 Basic Session Commands

ActionCommand
Start new tmux sessiontmux
Create named sessiontmux new -s [name]
Detach from sessionCtrl + B, then D
Attach to last sessiontmux a
Attach to specific sessiontmux a -t [name/id]
List sessionstmux ls
Kill current sessiontmux kill-session
Kill specific sessiontmux kill-session -t [name/id]

🪟 Window Management

ActionKey Combo
New windowCtrl + B, then C
Next windowCtrl + B, then N
Rename windowCtrl + B, then ,
List windowsCtrl + B, then W
Kill windowCtrl + B, then &

🧱 Pane Management (Splits)

ActionKey Combo
Split pane verticallyCtrl + B, then "
Split pane horizontallyCtrl + B, then %
Switch panesCtrl + B, then Arrow keys
Show pane numbersCtrl + B, then q
Jump to pane by indexCtrl + B, then q + number
Resize paneCtrl + B + Ctrl/Alt + Arrow keys

🎛️ Layout Presets

PresetKey Combo
Even vertical layoutCtrl + B, then Alt + 1
Even horizontal layoutCtrl + B, then Alt + 2
Main-horizontal layoutCtrl + B, then Alt + 3
Tiled (4 corners)Ctrl + B, then Alt + 4
Custom layoutCtrl + B, then Alt + 5

🔁 Persistence & Plugins

🧙 Scripting Sessions

#!/bin/bash
tmux new-session -d -s dev

tmux split-window -h
tmux send-keys -t 0 'htop' C-m
tmux send-keys -t 1 'docker ps' C-m

tmux attach-session -t dev

📦 YAML Workflows

Use Tmuxinator or Teamocil for YAML-based tmux project layouts.

📝 Sample .tmux.conf

# Vi-style keys
setw -g mode-keys vi

# Reload config with prefix + r
bind r source-file ~/.tmux.conf \; display "Reloaded!"

🔐 SSH Multiplexing + tmux = DevOps Heaven 💍

This combo ensures your SSH sessions are fast, stable, and tmux survives disconnections.

Step 1: Edit ~/.ssh/config

Host your-server.com
  HostName your-server.com
  User your_username
  ControlMaster auto
  ControlPath ~/.ssh/cm-%r@%h:%p
  ControlPersist 10m

Usage:

ssh your-server.com

Now tmux will stay up, even if SSH disconnects. Reconnect anytime and pick up where you left off.

🔌 Install & Use tpm (tmux plugin manager)

Step 1: Clone TPM

git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

Step 2: Add plugins to ~/.tmux.conf

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'

run '~/.tmux/plugins/tpm/tpm'

Step 3: Install Plugins

Optional: Auto Restore Sessions

set -g @continuum-restore 'on'
set -g @resurrect-capture-pane-contents 'on'

Crafted with ❤️ by Sreeju — for terminal pros who live on the edge.