Use tmux to keep multi-step terminal work organized
and recoverable across SSH disconnects. Create a named session,
detach and reattach cleanly, add a dedicated window for logs,
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 work organized and
accessible if your connection drops. You decide to use
tmux so you can detach, reconnect, and continue
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 ls) is an operational
check before attaching or killing anything.
monitor.
tmux new -s monitor
A named session makes reconnects predictable. Use names tied to the task to avoid attaching to the wrong workspace.
# You are now inside the tmux session.
# Start your monitoring or long-running work here.
Ctrl+b then d
Detaching leaves the session running on the server. This is the core reliability benefit of tmux during remote work.
[detached (from session monitor)]
tmux ls
This inventory check confirms what is running and provides the exact session name you should target.
monitor: 1 windows (created Tue Feb 10 04:00:00 2026) [80x24]
monitor session.
tmux attach -t monitor
Reattaching returns you to the exact session state so you can continue work without restarting processes.
[attached to monitor]
Ctrl+b then c
A new window gives you a dedicated workspace for logs, keeping monitoring and change execution separate.
# New window created.
logs.
Ctrl+b then ,
Window names reduce mistakes when you are switching quickly.
Use simple names like logs, shell,
or deploy.
# Window renamed to 'logs'.
tmux kill-session -t monitor
Killing the session ends all windows and panes under it. Terminate explicitly so you do not leave stale sessions on shared systems.
# Confirm the session is gone:
tmux ls
tmux is not installed. Install it with your distro package manager and confirm it is present in PATH.
tmux ls shows no sessions because you are
listing as a different user or the session was terminated.
Confirm your user and recreate the session if needed.
The target name is wrong or the session no longer exists.
Run tmux ls and attach using the exact name.
Always inventory first. Use tmux ls before any
destructive action so you do not terminate the wrong
workspace.
Ensure the monitor session does not persist after
the lab.
tmux ls
# If monitor still exists:
tmux kill-session -t monitor
tmux ls
tmux ls returns no sessions or does not list
monitor.
tmux new -s <name>
: Create a new session.
-s: session nametmux ls
: List sessions.
tmux attach -t <name>
: Attach to a session.
-t: target sessionCtrl+b
: Default prefix key.
Ctrl+b d
: Detach from the current session.
Ctrl+b c
: Create a new window.
Ctrl+b ,
: Rename the current window.
tmux kill-session -t <name>
: Terminate a session.