Attaching to an existing tmux session brings a saved shell workspace back onto the current terminal without restarting the commands already running inside it. That makes it the normal way to resume editors, logs, or long-running jobs after reconnecting to a server or opening a new terminal.
The attach-session command connects a client terminal to a session that already exists in the tmux server. From a normal shell it takes over the current terminal and draws the target session, while from inside tmux it switches the current client to that session instead of starting a nested tmux instance.
If no target is given, current tmux prefers the most recently used session that is not already attached to another client. Tmux does not create missing sessions during attach, and using -d detaches any other attached clients first, so the safest flow is to identify the right session name before taking it over.
Related: How to list tmux sessions
Related: How to create a tmux session
$ tmux list-sessions build: 1 windows (created Wed Apr 15 14:25:46 2026) ops: 2 windows (created Wed Apr 15 14:24:03 2026)
Use the session name at the start of each line as the -t target for the next command.
Related: How to list tmux sessions
$ tmux attach-session
If no -t target is given, current tmux prefers the most recently used session that is not already attached to another client.
$ tmux attach-session -t build build shell ready operator@server:~$ [build] 0:bash* "server" 14:25 15-Apr-26
From a normal shell this takes over the current terminal, and from inside tmux it switches the current client to build instead of nesting a second tmux instance.
$ tmux attach-session -d -t build
Every other client attached to build is disconnected immediately, so use -d only when taking over the session intentionally.
$ tmux attach-session -t build can't find session: build
Attach-session does not create sessions, so use How to create a tmux session when the target is missing and run How to list tmux sessions if the remembered name may be wrong.
[build] 0:bash*
The bracketed session name in the default status line is the quickest visual confirmation that the client is attached to build rather than a different session.