Files
MajorWiki/03-opensource/dev-tools/tmux.md
MajorLinux 6da77c2db7 wiki: remove Obsidian-style hashtag tags from 12 articles
These #hashtag tag lines render as plain text on MkDocs. All articles
already have tags in YAML frontmatter, so the inline tags were redundant.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 11:03:28 -04:00

2.1 KiB

tmux — Persistent Terminal Sessions

Problem

SSH sessions die when your connection drops, your laptop closes, or you walk away. Long-running jobs — storage migrations, file scans, downloads — get killed mid-run. You need a way to detach from a session, come back later, and pick up exactly where you left off.

Solution

tmux is a terminal multiplexer. It runs sessions that persist independently of your SSH connection. You can detach, disconnect, reconnect from a different machine, and reattach to find everything still running.

Installation (Fedora)

sudo dnf install tmux

Core Workflow

# Start a named session
tmux new-session -s mysession

# Detach from a session (keeps it running)
Ctrl+b, d

# List running sessions
tmux ls

# Reattach to a session
tmux attach -t mysession

# Kill a session when done
tmux kill-session -t mysession

Start a Background Job Directly

Skip the interactive session entirely — start a job in a new detached session in one command:

tmux new-session -d -s rmlint2 "rmlint /majorstorage// /mnt/usb// /majorRAID 2>&1 | tee /majorRAID/rmlint_scan2.log"

The job runs immediately in the background. Attach later to check progress:

tmux attach -t rmlint2

Capture Output Without Attaching

Read the current state of a session without interrupting it:

tmux capture-pane -t rmlint2 -p

Split Panes

Monitor multiple things in one terminal window:

# Horizontal split (top/bottom)
Ctrl+b, "

# Vertical split (left/right)
Ctrl+b, %

# Switch between panes
Ctrl+b, arrow keys

Real-World Use

On majorhome, all long-running storage operations run inside named tmux sessions so they survive SSH disconnects:

tmux new-session -d -s rmlint2 "rmlint ..."   # dedup scan
tmux new-session -d -s rsync-migrate "rsync ..."  # file migration
tmux ls  # check what's running

tmux vs screen

Both work. tmux has better split-pane support and scripting. screen is simpler and more universally installed. I use both — tmux for new jobs, screen for legacy ones. See the screen article for reference.