> sessions

Sessions are tmux's top-level containers: they hold your windows and panes and keep every process alive after you disconnect. This category covers spawning sessions, the idempotent attach-or-create pattern, hopping between multiple named sessions, and tearing them down cleanly — the commands you reach for when SSH drops or you want work to survive a closed terminal.

// sessions

16 commands

// faq

How do I reattach to a tmux session after my SSH connection drops?

Run `tmux attach` to reconnect to the most recent session, or `tmux attach -t mysession` for a specific one. The session and everything running inside it stayed alive on the server the whole time you were disconnected.

How do I create a session only if it doesn't already exist?

Use `tmux new-session -A -s mysession`. The `-A` flag makes it attach to `mysession` if that name already exists and create it otherwise, so the exact same command is safe to run from a script or shell profile every time.

What's the difference between detaching from and killing a session?

Detaching (`Ctrl + b d`) leaves the session and all its processes running in the background so you can reattach later. Killing (`kill-session` / `kill-server`) terminates the session and every process inside it immediately, with no way to recover them.