Most 'weird tmux' problems, like stale SSH agents or a config that will not apply, come from the client-server model.
tmux is a client-server program. The first tmux command starts a server daemon that owns all sessions, windows and pane processes. Each tmux invocation, including your attached terminal, is a client talking to it over a Unix socket, by default /tmp/tmux-<uid>/default (directory from $TMUX_TMPDIR).
tmux -L nameuses a different socket name, giving a completely separate server with its own config load;-S /pathgives a full socket path (useful for sharing a session between users via file permissions).$TMUXinside a pane holds the socket path, server pid and session index.kill-serverstops everything; the server also exits when its last session closes (optionexit-empty).
Several clients can attach to one session; window size follows the window-size option (latest by default since 3.1). A grouped session, tmux new -t main -s side, shares the same windows but keeps its own current window, so two people (or two monitors) can look at different windows of one workspace.
Environment capture: panes inherit the server's environment from when it started. When you reattach from a new SSH login, SSH_AUTH_SOCK and DISPLAY in old panes are stale. tmux copies the variables listed in update-environment into the session environment on attach, but existing shells do not see that; new panes do, and tmux show-environment lets a shell refresh them.
Example
echo "$TMUX" # /tmp/tmux-1000/default,12345,0
tmux -L work new -d -s a # separate server on socket 'work'
tmux -L work ls # a: 1 windows ...
tmux ls # default server: unaffected
tmux new -d -s main
tmux new -t main -s side # grouped: same windows, own current window
tmux show-options -g update-environment
# refresh a stale agent socket in an old pane:
eval "$(tmux show-environment -s SSH_AUTH_SOCK)"Remember
- One server per socket; -L name or -S path selects another
- Grouped sessions share windows but not the current window
- Old panes keep the environment from when they started; use show-environment -s
Watch out for
- Assuming panes pick up a new SSH_AUTH_SOCK after reattaching; only new panes get the updated value.