Using tmux for Persistent Terminal Sessions

Using tmux for Persistent Terminal Sessions

tmux is a terminal multiplexer that keeps your sessions alive after SSH disconnects — essential for long-running tasks on a server.

Install tmux

apt install tmux -y    # Ubuntu/Debian
dnf install tmux -y    # CentOS/RHEL

Start a New Session

tmux new -s mysession

Detach from a Session (Session Stays Running)

Press Ctrl+B then D

List Sessions

tmux ls

Reattach to a Session

tmux attach -t mysession

Kill a Session

tmux kill-session -t mysession

Key Shortcuts (all preceded by Ctrl+B)

  • Ctrl+B % — split pane vertically
  • Ctrl+B " — split pane horizontally
  • Ctrl+B arrow — move between panes
  • Ctrl+B c — create new window
  • Ctrl+B n — next window
  • Ctrl+B p — previous window
  • Ctrl+B & — kill current window
  • Ctrl+B [ — enter scroll/copy mode (use arrow keys, q to exit)

Basic ~/.tmux.conf

# Enable mouse support
set -g mouse on
# Increase scrollback buffer
set -g history-limit 10000
# Start windows at 1
set -g base-index 1

Reload config: tmux source-file ~/.tmux.conf

  • 0 Benutzer fanden dies hilfreich
War diese Antwort hilfreich?

Verwandte Artikel

Managing Users and Groups

Managing Users and Groups on Linux Proper user management is essential for server security. Avoid...

Managing Services with systemctl

Managing Services with systemctl systemctl is the standard tool for managing services on modern...

Monitoring Server Resources

Monitoring Server Resources Keeping an eye on your server's resource usage helps you identify...

Scheduling Tasks with Cron

Scheduling Tasks with Cron Cron allows you to schedule commands to run automatically at set...

Installing and Configuring Nginx

Installing and Configuring Nginx Nginx is a high-performance web server and reverse proxy widely...