Hostxpeed
Login Get Started →
Getting Started

How to Use Tmux

7 min read
24 views
Jun 10, 2026

Prerequisites

Before using tmux, make sure you have:

  • SSH access to your VPS
  • Tmux installed on your server

💡 Tmux is more modern than Screen, with better window management, panes, and customization options.

Step 1: Install Tmux

Ubuntu/Debian:

apt update
apt install tmux -y

CentOS/Rocky:

yum install tmux -y

Step 2: Start a New Tmux Session

tmux new -s mysession

Replace mysession with a descriptive session name.

You are now inside tmux (green bar at bottom).

Step 3: Run Your Command

apt upgrade -y

Or any long-running process.

Step 4: Detach from Session (Ctrl+B, then D)

Press:

Ctrl + B, then D

You will see:

[detached from mysession]

Your command keeps running.

Step 5: Exit SSH

exit

Step 6: List and Reattach Later

Reconnect via SSH, then:

tmux ls

Output:

mysession: 1 windows (created Mon Apr 28 10:30:15 2026)

Reattach:

tmux attach -t mysession

Essential Tmux Commands (Prefix: Ctrl+B)

Session management:

  • Ctrl+B, D - Detach session
  • Ctrl+B, S - List sessions (choose with arrow keys)
  • Ctrl+B, $ - Rename session

Window management:

  • Ctrl+B, C - Create new window
  • Ctrl+B, N - Next window
  • Ctrl+B, P - Previous window
  • Ctrl+B, 0-9 - Switch to window number
  • Ctrl+B, , - Rename window
  • Ctrl+B, & - Kill current window

Pane management (split screen):

  • Ctrl+B, % - Split vertically (left/right)
  • Ctrl+B, " - Split horizontally (top/bottom)
  • Ctrl+B, Arrow keys - Move between panes
  • Ctrl+B, X - Kill current pane
  • Ctrl+B, Z - Zoom pane (fullscreen)
  • Ctrl+B, Space - Change layout

Copy mode (scrollback):

  • Ctrl+B, [ - Enter copy mode
  • Arrow keys/PgUp/PgDn - Scroll
  • Q - Exit copy mode

Practical Examples

Multiple Panes for Monitoring

tmux new -s monitor
Ctrl+B, %
# Left pane: htop
Ctrl+B, Left Arrow
htop
Ctrl+B, Right Arrow
# Right pane: watch uptime
watch -n 1 uptime

Three Pane Layout

tmux new -s dashboard
Ctrl+B, "     (split horizontal)
Ctrl+B, %     (split right pane vertically)
# Now you have 3 panes

Kill a Tmux Session

From inside tmux:

exit

Or kill all windows (Ctrl+B, &).

From outside:

tmux kill-session -t mysession

Customize Tmux (Create ~/.tmux.conf)

nano ~/.tmux.conf

Add these useful settings:

# Use Ctrl+A instead of Ctrl+B (like screen)
unbind C-b
set-option -g prefix C-a
bind C-a send-prefix

# Mouse support
set -g mouse on

# Better colors
set -g default-terminal "screen-256color"

# Increase scrollback buffer
set -g history-limit 10000

# Easy reload config
bind r source-file ~/.tmux.conf \; display "Config reloaded"

# Split panes with H/V
bind | split-window -h
bind - split-window -v

Reload config:

tmux source-file ~/.tmux.conf

Save and Restore Tmux Sessions (with tmux-resurrect)

Install plugin manager:

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

Add to ~/.tmux.conf:

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
run '~/.tmux/plugins/tpm/tpm'

Reload and install:

tmux source ~/.tmux.conf
# Press Ctrl+B, then Shift+I

Save session: Ctrl+B, Ctrl+S

Restore session: Ctrl+B, Ctrl+R

Common Use Cases

  • Running multiple services simultaneously
  • Monitoring logs (tail -f) across multiple files
  • Database migrations
  • Long-running data processing
  • Remote development
  • Team pairing sessions (tmux can be shared)

Tmux vs Screen Comparison

  • Panels - Tmux has better split pane support
  • Scripting - Tmux has more powerful scripting
  • Performance - Similar for most use cases
  • Customization - Tmux is more configurable
  • Learning curve - Screen is simpler, Tmux more powerful

✅ You can now use tmux for advanced terminal session management on your Hostxpeed VPS.

Was this article helpful?