Home/Engineer/Linux / Shell/tmux for Remote Servers: Kee…
Linux / ShellBeginnerUbuntuDebianCentOSmacOStmuxproductivity

tmux for Remote Servers: Keeping Sessions Alive Across Disconnects and Splitting Windows and Panes

tmux is an essential tool for remote server work. This practical guide covers session persistence, window splitting, and configuration customization.

Contents
  1. Why You Need tmux
  2. Session Management
  3. Key Bindings (default prefix: Ctrl+b)
  4. Recommended ~/.tmux.conf Settings
  5. Practical Patterns
  6. Copying in Scroll Mode

Why You Need tmux

Your work keeps running even if the SSH connection drops. Run deploy scripts, builds, and monitoring inside tmux, and they continue on the server even when a network issue disconnects your session.


Session Management

Bash
# Start a new session
tmux new -s deploy

# List sessions
tmux ls

# Reattach to a session (come back after detach)
tmux attach -t deploy

# Kill a session
tmux kill-session -t deploy

Key Bindings (default prefix: Ctrl+b)

ShortcutAction
Ctrl+b dDetach session (session stays alive)
Ctrl+b cCreate a new window
Ctrl+b n / pNext / previous window
Ctrl+b 0~9Jump to window by number
Ctrl+b %Split pane vertically
Ctrl+b "Split pane horizontally
Ctrl+b arrow keysMove between panes
Ctrl+b zToggle current pane zoom (fullscreen)
Ctrl+b [Enter scroll mode (q to exit)
Ctrl+b ,Rename window

Bash
# Change prefix to Ctrl+a (optional)
unbind C-b
set -g prefix C-a
bind C-a send-prefix

# Enable mouse (scroll, click panes)
set -g mouse on

# Start window numbering at 1
set -g base-index 1
setw -g pane-base-index 1

# Status bar colors
set -g status-bg colour235
set -g status-fg colour136

# Increase history size
set -g history-limit 10000

# Reload config immediately
bind r source-file ~/.tmux.conf \; display "Config reloaded!"

Apply the config: Ctrl+b r or tmux source ~/.tmux.conf


Practical Patterns

Bash
# Set up a deploy session (automated)
tmux new-session -d -s prod -n monitor
tmux send-keys -t prod:monitor "htop" Enter
tmux new-window -t prod -n logs
tmux send-keys -t prod:logs "tail -f /var/log/app/app.log" Enter
tmux new-window -t prod -n shell
tmux attach -t prod

# Type into multiple panes at once (synchronize)
# Ctrl+b :setw synchronize-panes on

Copying in Scroll Mode

  1. Enter scroll mode with Ctrl+b [
  2. Move with arrow keys or PageUp/PageDown
  3. Start selection with Space, then extend the range with arrow keys
  4. Copy with Enter (tmux clipboard)
  5. Paste with Ctrl+b ]
#tmux#productivity
Editorial note

AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us

Topic-related official docs (auto-linked · not per-claim sources)Linux man pages ↗

Questions & answers

Ask a question about this guide. We'll review and reply.