To attach to tmux session 0, use the command tmux attach -t 0
or the shorter form tmux a -t 0
.
$ tmux attach -t 0
tmux automatically numbers sessions sequentially starting from 0. Session 0 is typically the first session created unless it was explicitly given a name. Attaching to session 0 is a common operation when you've just started using tmux or have a simple setup with one primary session.
Before attaching, you can verify that session 0 exists by listing all current sessions:
$ tmux list-sessions
Or using the shorter form:
$ tmux ls
You should see output like this if session 0 exists:
0: 3 windows (created Sat Jun 1 10:42:33 2025) [80x24] dev: 2 windows (created Sat Jun 1 09:15:22 2025) [80x24]
To attach to session 0, use:
$ tmux attach -t 0
If session 0 doesn't exist, you'll get an error like:
can't find session 0
In this case, you have two options:
tmux new-session -s 0
tmux new-session -A -s 0
Consider using named sessions instead of numbered ones for clarity. A descriptive name like "dev" or "project" is easier to remember than a number.
When connecting to a remote server, you can combine SSH and tmux attach in one command: ssh user@host -t 'tmux attach -t 0 || tmux new -s 0'