Scenario
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.
Objective
- Start a new tmux session named
monitor. - Detach from the session without ending it.
- List available tmux sessions.
- Reattach to the
monitorsession. - Create a new window and rename it to
logs. - Terminate the session cleanly.
Concepts
- A tmux session is a persistent workspace that survives SSH disconnects.
- Windows separate tasks inside a session, reducing mistakes during remote operations.
- Detach keeps processes running server-side while you drop back to the normal shell.
-
Session inventory (
tmux ls) is an operational check before attaching or killing anything. - Explicit termination prevents stale sessions and makes the end of a change unambiguous.
Walkthrough
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
Common breakpoints
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.
Cleanup checklist
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.
Reference
-
tmux new -s <name>: Create a new session.-s: session name
-
tmux ls: List sessions. -
tmux attach -t <name>: Attach to a session.-t: target session
-
Ctrl+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.