Use tmux to keep multiple workflows organized and
recoverable across SSH disconnects. Start a named session,
detach and reattach cleanly, create and name a window for log
work, and terminate the session when the task is complete.
You are managing multiple long-running processes on a remote
system and need a reliable way to keep sessions organized and
accessible if your connection drops. You decide to use
tmux so you can detach, reconnect, and continue
work without losing state.
Terminal multiplexers are baseline tooling for remote operations. They reduce failure risk during maintenance and make it easier to separate “monitoring,” “logs,” and “change execution” into explicit workspaces.
monitor.monitor session.logs.tmux new -s.
Ctrl+b then d).
tmux ls /
tmux list-sessions.
tmux attach -t.
tmux kill-session.
monitor.
tmux new -s monitor
A named session makes it easy to reconnect later. In production, naming sessions after the task (“monitor,” “upgrade,” “incident”) reduces confusion.
tmux session 'monitor' started.
Ctrl+b d
Detaching keeps the session alive on the server while your SSH connection comes and goes. This is the core reliability benefit of tmux.
Detached from 'monitor' session.
tmux ls
# OR
tmux list-sessions
Listing sessions confirms what is currently running and provides the exact session name to reattach.
monitor: 1 windows (created Tue Jul 23 14:00:00 2025) [80x24]
monitor session.
tmux attach -t monitor
Reattaching returns you to the exact session state. This is how you resume monitoring or long-running operations without restarting processes.
Reattached to 'monitor' session.
Ctrl+b c
Windows are separate workspaces within a session. Use them to keep monitoring, log review, and change execution separated so you can switch contexts safely.
New tmux window created.
logs.
Ctrl+b ,
Naming windows makes multi-window sessions usable under pressure. “logs” is a common convention for a window used for tailing or reviewing system messages.
Window renamed to 'logs'.
This lab’s script attempts to kill the session using a
window name, but kill-session -t targets a
session, not a window. The correct target here is the
session name: monitor.
tmux kill-session -t monitor
Terminating the session explicitly prevents stale sessions from accumulating. In real environments, stale sessions can hide unfinished work and confuse future operators.
Session 'monitor' terminated.
tmux new -s <name>
: Creates a new session with a specific name.
-s
: Sets the session name.
Ctrl+b
: Default tmux prefix key. Most tmux actions begin with
prefix then a command key.
Ctrl+b d
: Detaches from the current session without ending it.
tmux ls
/
tmux list-sessions
: Lists existing tmux sessions.
tmux attach -t <name>
: Attaches to a session by name.
-t
: Targets a specific session.
Ctrl+b c
: Creates a new window.
Ctrl+b ,
: Renames the current window.
tmux kill-session -t <session>
: Terminates a session by name.