[tmux.app]
tmux 3.8

Guide · Sessions

tmux sessions: create, list, attach, detach and kill

A tmux session is a workspace that keeps running on the machine after you close your terminal or lose SSH. Start one with tmux new -s work, leave it with Ctrl+b d, list sessions with tmux ls, come back with tmux attach -t work, and end it with tmux kill-session -t work.

Updated Tested on tmux 3.815 min read

On this page
  1. tmux session management: every command at a glance
  2. What a tmux session is, and why it survives
  3. How to create a new tmux session
  4. tmux list sessions: how to see every session
  5. tmux attach: how to reattach to a session
  6. How to switch between tmux sessions
  7. tmux detach: how to leave a session running
  8. How to rename a tmux session
  9. tmux kill session: how to end one session
  10. tmux kill all sessions: how to stop everything at once
  11. Nested sessions: tmux inside tmux
  12. tmux sessions over SSH
  13. Share a session, or view it twice
  14. Script a session: one command for your whole workspace
  15. Save and restore sessions after a reboot
  16. Common tmux session errors
  17. Frequently asked questions

Quick answer

The five session commands you need

shell
tmux new -s work               # create a session named "work" and attach
tmux ls                        # list sessions
tmux attach -t work            # reattach (short: tmux a -t work)
tmux kill-session -t work      # kill one session
tmux kill-server               # kill every session

Inside tmux, press Ctrl+b d to detach (the prefix is Ctrl+b: press it, let go, then press d). Everything here is checked on tmux 3.8, with notes where 3.4 (Ubuntu 24.04) behaves differently.

Watch: keep jobs running when SSH drops. Create, detach, reattach and manage tmux sessions in 3 minutes.

tmux session management: every command at a glance

Every session command has a long name, a short alias, and often a key binding you use from inside tmux. Pick your prefix to update the keys on this page:

Your prefix
TaskCommandShort formInside tmux
New named sessiontmux new-session -s worktmux new -s workCtrl+b : new -s work
List sessionstmux list-sessionstmux lsCtrl+b s
Attachtmux attach-session -t worktmux a -t work(switch instead)
Attach or createtmux new-session -A -s worktmux new -As work
Detachtmux detach-clienttmux detachCtrl+b d
Switch sessiontmux switch-client -t apitmux switchc -t apiCtrl+b ( Ctrl+b ) Ctrl+b Shift+Tab
Renametmux rename-session -t old newtmux rename newCtrl+b $
Kill one sessiontmux kill-session -t workCtrl+b : kill-session
Kill all but this onetmux kill-session -a
Kill every sessiontmux kill-server

The same rules apply to every command: -t picks the target (see target syntax), and any unambiguous prefix of a command name works, so tmux a, tmux at and tmux attach are the same thing. All the default key bindings are on the cheat sheet.

Which command do I need?

I want to…

Start a new session

shell
tmux new -s work

Already inside tmux? Use tmux new -d -s work and then switch to it, or tmux refuses with a nesting error. More options →

See which sessions exist

shell
tmux ls

Inside tmux, Ctrl+b s shows them as a tree with a live preview. Formats and filters →

Get back into a session

shell
tmux attach -t work

Plain tmux attach picks the most recently used session. tmux new -A -s work attaches if work exists and creates it if not. More →

Leave, but keep everything running

Press Ctrl+b d, or run tmux detach. Closing the terminal window or losing SSH has the same effect: the session keeps going. More →

Jump to another session without detaching

Ctrl+b s to pick from a list, Ctrl+b ( and Ctrl+b ) for previous and next, or Ctrl+b Shift+Tab for the fuzzy switcher in 3.8. From the command line inside tmux:

shell
tmux switch-client -t api

More →

Rename a session

Inside tmux, press Ctrl+b $, edit the name, press Enter. From anywhere:

shell
tmux rename-session -t old new

More →

Close one session and everything in it

shell
tmux kill-session -t work

To be sure you hit exactly work and not workshop, write -t =work. More →

Close every session

shell
tmux kill-server

To keep the session you are in and close the rest: tmux kill-session -a. More →

What a tmux session is, and why it survives

When you run tmux, two things start: a server in the background, and a client, which is the tmux you see in your terminal. The server owns every session. A session holds one or more windows (the tabs in the status line), and each window holds one or more panes, each running a shell or program.

Your terminal only shows a session; it does not own it. Detaching, closing the window or losing an SSH connection kills the client, but the server and every program in the session keep running until you kill the session or the machine shuts down. That is the whole reason people run long jobs, servers and AI agents inside tmux.

The life of a tmux session tmux new -s work creates a session and attaches to it; tmux new -d -s work creates it detached. Prefix d, or a dropped SSH connection, moves an attached session to detached, where it keeps running. tmux attach -t work moves it back to attached. Typing exit in the last shell, or tmux kill-session -t work, ends the session and every program in it. tmux kill-server ends every session at once. No session nothing running Attached a terminal shows it, your keys go to it Detached still running in the background, no terminal Session gone its programs end tmux new -s work tmux new -d -s work prefix d or SSH drops tmux attach -t work exit in the last pane tmux kill-session -t work kill-server: all at once
A session is created attached or detached, moves between the two as often as you like, and only ends when its last shell exits or you kill it.

The server listens on a socket, by default /tmp/tmux-UID/default (for example /tmp/tmux-1000/default). Every tmux command you type, including tmux ls, is a small client that talks to that socket. When the last session ends, the server exits too (the exit-empty option, on by default).

The everyday workflow

  1. Create a named session

    shell
    tmux new -s work

    The status line appears at the bottom with [work] on the left. Start whatever you need: an editor, a build, a server.

  2. Detach and walk away

    Press Ctrl+b d. You are back in your normal shell and tmux prints [detached (from session work)]. Everything keeps running.

  3. List what is running

    shell
    tmux ls
    work: 2 windows (created Tue Oct 28 09:14:02 2026)
  4. Reattach, from this machine or over SSH

    shell
    tmux attach -t work

    The screen comes back exactly as you left it, including output that arrived while you were away.

  5. Kill it when you are done

    shell
    tmux kill-session -t work

    Or type exit in every pane: when the last shell exits, the session ends.

How to create a new tmux session

Quick answer

How do I create a named tmux session?

Run tmux new -s work. It creates a session called work and attaches to it. tmux new is short for tmux new-session; with no -s, tmux names the session with a number.

create sessions
# named session, attached
tmux new -s work
# create it in the background, without attaching
tmux new -d -s work
# start in a directory and name the first window
tmux new -s api -n server -c ~/projects/api
# attach if "work" exists, create it if not (great for SSH logins)
tmux new -A -s work
# run a command as the first window's program
tmux new -d -s logs 'tail -f /var/log/syslog'
# set an environment variable and a size for a detached session
tmux new -d -s ci -e CI=1 -x 200 -y 50
FlagWhat it does
-s nameSession name. Without it, tmux uses a number.
-dCreate the session detached, in the background. Use this in scripts and from inside tmux.
-AIf the session already exists, attach to it instead of failing with duplicate session.
-n nameName of the first window.
-c dirStart directory for the session (new windows open there too).
-x / -yWidth and height for a detached session. Otherwise the default-size option (80x24) applies until a client attaches.
-e VAR=valueSet an environment variable in the session. Repeat for more.
-t groupJoin a session group: share the windows of another session.
-P / -FPrint the new session's name (or a format) after creating it. Handy in scripts.

Naming sessions

Use short names made of letters, digits, - and _: api, blog-draft, client_x. Names with spaces work but need quotes every time. Avoid dots and colons: tmux 3.4 silently turns them into underscores (my.project becomes my_project), and while tmux 3.8 keeps them, -t my.project is then read as a window and pane target and fails with can't find pane: project.

Unnamed sessions get the next free session number, which is not always 0: if you created two named sessions first, the next unnamed one is called 2. Rename it any time with Ctrl+b $.

tmux list sessions: how to see every session

Quick answer

How do I list all tmux sessions?

Run tmux ls (short for tmux list-sessions). Each line shows a session's name, its window count, when it was created, and (attached) if a terminal is showing it. Inside tmux, press Ctrl+b s for an interactive list. To check whether any tmux sessions are running at all from a script, use tmux has-session (exit status 0 if a server with sessions is running).

list sessions
tmux ls
api: 3 windows (created Tue Oct 28 17:54:11 2026)
logs: 1 windows (created Tue Oct 28 17:54:11 2026)
work: 2 windows (created Tue Oct 28 17:54:11 2026) (attached)
# just the names, one per line (for scripts)
tmux ls -F '#{session_name}'
# name and window count
tmux ls -F '#{session_name} #{session_windows}'
# only sessions nobody is attached to
tmux ls -f '#{==:#{session_attached},0}'
# sorted by name, or by most recent activity (tmux 3.7 and later)
tmux ls -O name
tmux ls -O activity -r
# does a session exist? exit status 0 = yes, 1 = no
tmux has-session -t work && echo exists
Real screenshot · tmux 3.8tmux ls on tmux 3.8, then the same list with a custom -F format.
tmux ls on tmux 3.8, then the same list with a custom -F format.
How this was captured

Captured 2026-10-28 17:55 UTC from a real xterm window running tmux 3.8 on Ubuntu 24.04. Nothing is mocked up. The commands that set up the screen:

tmux new-session -d -s work -n editor -x 100 -y 23
tmux new-window -d -t work -n tests
tmux new-session -d -s api
tmux new-window -d -t api
tmux new-window -d -t api
tmux new-session -d -s logs
tmux send-keys -t work clear Enter
tmux send-keys -t work 'tmux ls' Enter
tmux send-keys -t work 'tmux ls -F '"'"'#{session_name}: #{session_windows} windows, attached=#{session_attached}'"'"'' Enter

-F takes a format: text with #{variables} filled in for each session. The useful ones are session_name, session_windows, session_attached (number of clients), session_created and session_activity (Unix times; #{t:session_created} prints a date), session_path and session_group. -f is a filter in the same syntax: only sessions where it is true are shown. -O (sort by index, name, creation or activity) and -r (reverse) are new in tmux 3.7; older versions have only -F and -f.

See and manage sessions interactively

Inside tmux, Ctrl+b s opens the session tree (choose-tree -s) and Ctrl+b w opens the same tree expanded to windows. Move with the arrow keys, press Enter to switch, → to expand a session, x to kill the selected session (tmux asks first), t to tag several and X to kill all tagged ones, and q to leave.

Real screenshot · tmux 3.8Prefix s opens the session tree (choose-tree -Zs) with a live preview.
Prefix s opens the session tree (choose-tree -Zs) with a live preview.
How this was captured

Captured 2026-10-28 17:54 UTC from a real xterm window running tmux 3.8 on Ubuntu 24.04. Nothing is mocked up. The commands that set up the screen:

tmux new-session -d -s work -n editor -x 100 -y 23
tmux new-window -d -t work -n tests
tmux new-session -d -s api -n server
tmux new-window -d -t api -n db
tmux new-session -d -s logs -n tail
tmux send-keys -t work 'clear; echo '"'"'press prefix s to pick a session'"'"'' Enter
(typed in the terminal) C-b s

tmux attach: how to reattach to a session

Quick answer

How do I reattach to a tmux session?

Run tmux attach -t work (or tmux a -t work). With no -t, tmux attach picks the most recently used session, preferring one that nobody is attached to.

attach to sessions
# by name, or by number for unnamed sessions
tmux attach -t work
tmux attach -t 0
# the most recent session
tmux attach
# attach, or create it if it does not exist
tmux new -A -s work
# attach and detach everyone else (fixes a tiny window from another client)
tmux attach -d -t work
# watch someone's session without being able to type
tmux attach -r -t work
# from another computer: log in and attach in one step
ssh -t user@server tmux new -A -s main
FlagWhat it does
-t nameThe session to attach to. Matches an exact name first, then a unique start of a name, so -t ap finds api. Use -t =api for an exact match only.
-dDetach every other client from the session. The window then sizes to your terminal only.
-xLike -d, and also send SIGHUP to the other clients' parent process, which usually closes their terminal or SSH login.
-rRead-only: you see everything, but only detach and switch keys work. Same as -f read-only,ignore-size.
-c dirChange the session's working directory, used for new windows from now on.
-f flagsClient flags, for example ignore-size so your terminal does not shrink the window for others.

Several terminals can attach to one session at the same time; they all see and control the same thing. The window takes the size of the terminal used most recently (window-size latest, the default), so a smaller screen may show dots around the edge. That is how people pair program over SSH.

Errors you may see when attaching

MessageMeaning and fix
can't find session: workNo session has that name (or the start of the name matches more than one). Run tmux ls and copy the exact name.
no sessionsThe server is running but has no sessions, or tmux attach started a fresh server. Create one with tmux new -s work, or use tmux new -A -s work so it never fails.
sessions should be nested with care, unset $TMUX to forceYou are already inside tmux. Switch instead: tmux switch-client -t work. See nested sessions.
open terminal failed: not a terminaltmux was run without a terminal, for example ssh host tmux attach or from cron. Add -t to ssh, or create sessions with -d in scripts.
server exited unexpectedly or protocol version mismatchA different tmux version is talking to a running server, usually after an upgrade. Use the old binary to attach, or kill the old server. See troubleshooting.

How to switch between tmux sessions

Quick answer

How do I switch to another session from inside tmux?

Press Ctrl+b s and pick one, or run tmux switch-client -t api. Do not run tmux attach inside tmux: that nests one session inside another.

Keys / commandGoes to
Ctrl+b sA tree of sessions with a preview; Enter switches
Ctrl+b ( / Ctrl+b )The previous / next session, in name order, wrapping around
Ctrl+b LThe last session you were in (toggle between two)
Ctrl+b Shift+Tab new in 3.8A fuzzy session switcher: type part of a name, press Enter
tmux switch-client -t apiA named session (-l, -n, -p for last, next, previous)

The 3.8 switcher opens in a floating pane and also has a window version on Ctrl+b Tab, covered in the windows guide.

tmux detach: how to leave a session running

Quick answer

How do I exit tmux without killing the session?

Detach: press Ctrl+b d (Ctrl+b, then d). You return to the shell you started tmux from, and the session keeps running. Typing exit does the opposite: it closes the pane, and the session if it was the last one.

detach
# from a shell inside tmux: same as prefix d
tmux detach
# detach every other terminal from this session, keep yours
tmux detach -a
# detach all clients attached to the session "work" (from anywhere)
tmux detach -s work
# detach and close the terminal or SSH login that ran tmux
tmux detach -P
Real screenshot · tmux 3.8Prefix d detaches: the client exits, the session and its job keep running.
Prefix d detaches: the client exits, the session and its job keep running.
How this was captured

Captured 2026-10-28 17:54 UTC from a real xterm window running tmux 3.8 on Ubuntu 24.04. Nothing is mocked up. The commands that set up the screen:

tmux new-session -d -s work -x 90 -y 13
tmux send-keys -t work 'clear; sleep 3600 # a long job' Enter
(typed in the terminal) C-b d

Ctrl+b D lists every attached client so you can pick one to detach, which is useful when an old laptop is still attached and keeping the window small. Closing the terminal window, or losing your SSH connection, detaches too: the client gets a hangup signal and exits, and the server carries on.

What keeps running after you detach

Everything inside the session: shells, editors, builds, servers, tail -f, AI coding agents. Output that arrives while you are away is kept in each pane's scrollback (2,000 lines per pane by default; see history-limit). Sessions end only when you kill them, when their last shell exits, or when the server dies: a reboot, tmux kill-server, or a system that kills all user processes on logout (systemd-logind with KillUserProcesses=yes).

How to rename a tmux session

Quick answer

How do I rename a tmux session?

Inside tmux, press Ctrl+b $, edit the name and press Enter. From any shell: tmux rename-session -t old new.

rename
tmux rename-session -t 0 work
# inside tmux, -t can be left out: renames the current session
tmux rename work

Ctrl+b $ opens a prompt reading (rename-session) work with the current name filled in; Ctrl+u clears it. If the new name is taken you get duplicate session: name. Windows are renamed separately, with Ctrl+b , (see windows).

tmux kill session: how to end one session

Quick answer

How do I kill (close, delete) a tmux session?

Run tmux kill-session -t work. It closes the session, every window and pane in it, and the programs they run, and detaches anyone attached. To kill the session you are in, press Ctrl+b :, type kill-session and press Enter.

kill one session
# by name, from any shell
tmux kill-session -t work
# exact name only (will not match "workshop")
tmux kill-session -t =work
# unnamed sessions are numbers
tmux kill-session -t 2
# inside tmux, no -t: kills the current session
tmux kill-session
Real screenshot · tmux 3.8Killing a session, then trying again: the real error and the list afterwards.
Killing a session, then trying again: the real error and the list afterwards.
How this was captured

Captured 2026-10-28 18:08 UTC from a real xterm window running tmux 3.8 on Ubuntu 24.04. Nothing is mocked up. The commands that set up the screen:

tmux new-session -d -s work -x 100 -y 15
tmux new-session -d -s api
tmux new-session -d -s scratch
tmux send-keys -t work 'clear; tmux ls' Enter
tmux send-keys -t work 'tmux kill-session -t scratch' Enter
tmux send-keys -t work 'tmux kill-session -t scratch' Enter
tmux send-keys -t work 'tmux ls' Enter

"Delete", "close", "end", "stop", "terminate" and "remove" a session all mean kill-session; there is no separate delete command. Two details catch people out:

  • Names match by prefix. If no session is called exactly ap, then -t ap kills api. When the start matches two sessions, tmux refuses with can't find session: ap. In scripts, always write -t =name.
  • No -t outside tmux kills the most recently used session, which may not be the one you meant. Always name the target from a plain shell.

When you kill the session you are attached to, your terminal is detached and you are back at your shell (that is detach-on-destroy on, the default). To jump to another session instead, add set -g detach-on-destroy off to your config. Killing from the session tree also works: Ctrl+b s, select a session, press x, then y.

The gentle way to end a session is to quit its programs and type exit in each pane; when the last pane closes, the session goes. Use kill-session when you want everything gone now, including programs that would ask you to save. kill-session -C is unrelated to killing: it only clears bell and activity alerts on the session's windows.

tmux kill all sessions: how to stop everything at once

Quick answer

How do I kill all tmux sessions at once?

Run tmux kill-server. It ends every session and the tmux server itself. To keep the session you are in and kill all the others, run tmux kill-session -a.

kill many sessions
# everything: all sessions, all clients, the server
tmux kill-server
# all sessions except the current one (inside tmux)
tmux kill-session -a
# all sessions except "main" (from anywhere)
tmux kill-session -a -t main
# all sessions except main whose name starts with "scratch" (tmux 3.8)
tmux kill-session -a -t main -f '#{m:scratch*,#{session_name}}'
# every session in the same group as work-2 (tmux 3.7 and later)
tmux kill-session -g -t work-2
# older tmux: kill sessions matching a pattern one by one
tmux ls -F '#{session_name}' | grep '^scratch' | xargs -I{} tmux kill-session -t ={}
CommandSessions killedServer afterwards
tmux kill-session -t xOnly xKeeps running if other sessions exist
tmux kill-session -aAll except the current (or the -t) oneKeeps running
tmux kill-session -a -f …All except the target, for which the filter is true (3.8)Keeps running
tmux kill-serverAllExits

After kill-server, tmux ls reports no server running on /tmp/tmux-1000/default, which is what you want. If the server is stuck and does not respond, pkill -u "$USER" tmux is the last resort; everything in your sessions is lost.

Nested sessions: tmux inside tmux

Quick answer

What does 'sessions should be nested with care, unset $TMUX to force' mean?

You ran tmux, tmux new or tmux attach from a shell that is already inside tmux. tmux stops you because a session inside a session is rarely what you want. Use tmux switch-client -t name to move to another session instead.

Real screenshot · tmux 3.8Running tmux inside tmux: the real error message.
Running tmux inside tmux: the real error message.
How this was captured

Captured 2026-10-28 17:54 UTC from a real xterm window running tmux 3.8 on Ubuntu 24.04. Nothing is mocked up. The commands that set up the screen:

tmux new-session -d -s work -x 90 -y 11
tmux send-keys -t work 'clear; tmux new -s other' Enter

To create a session from inside tmux without nesting, add -d and then switch: tmux new -d -s other, then tmux switch-client -t other. If you really want tmux inside tmux, for example a local tmux with an SSH session to a server that runs its own tmux, that works without any override: the remote shell does not have your local $TMUX. To force it on one machine, run TMUX= tmux new -s inner.

In a nested setup, the outer tmux catches the prefix. Press it twice to reach the inner one: Ctrl+b Ctrl+b sends a literal Ctrl+b through (the send-prefix binding). Many people give the outer tmux a different prefix, such as Ctrl+a, in its config.

tmux sessions over SSH

Run tmux on the server, not on your laptop, so the session lives where the work happens. One command logs in and attaches, creating the session the first time:

shell
ssh -t user@server tmux new -A -s main

The -t gives tmux a terminal; without it you get open terminal failed: not a terminal. If the connection drops, nothing is lost: run the same command again. For copy and paste from a remote tmux to your local clipboard, see OSC 52 over SSH.

Share a session, or view it twice

Two terminals attached to the same session see the same window. To look at different windows of the same session at the same time, create a session group: a second session that shares the first one's windows but has its own current window.

shell
tmux new -d -s work
tmux new -t work -s work-2
tmux ls
work: 1 windows (created Tue Oct 28 17:59:25 2026) (group work)
work-2: 1 windows (created Tue Oct 28 17:59:25 2026) (group work)

Killing work-2 leaves work and its windows alone. For sharing with another user, read-only guests and tmate, see pair programming with tmux.

Script a session: one command for your whole workspace

Every key press in tmux is a command, so a short shell script can build a session with its windows, panes and programs, and reattach if it is already running. This one is safe to run again and again:

dev.sh
#!/bin/sh
# dev.sh: open (or reopen) a "dev" workspace
S=dev
DIR="$HOME/projects/myapp"
if ! tmux has-session -t "=$S" 2>/dev/null; then
  tmux new-session -d -s "$S" -n editor -c "$DIR"
  tmux send-keys -t "$S:editor" 'nvim .' Enter
  tmux split-window -h -t "$S:editor" -c "$DIR" -l 40%
  tmux send-keys -t "$S:editor.1" 'npm run dev' Enter
  tmux new-window -d -t "$S" -n git -c "$DIR"
  tmux select-pane -t "$S:editor.0"
fi
if [ -n "$TMUX" ]; then
  tmux switch-client -t "=$S"
else
  tmux attach -t "=$S"
fi

The pattern is: create detached with -d, target everything with -t session:window.pane, then attach at the end, or switch if the script runs inside tmux. We ran this script on tmux 3.8 and 3.4. More patterns, send-keys and capture-pane details and Python control are in tmux scripting.

For many projects, a session manager saves writing scripts by hand: tmuxinator (YAML, Ruby) and tmuxp (YAML or JSON, Python) describe a workspace in a file and start it with one command; sesh and tmux-sessionx are fuzzy pickers for jumping between project sessions. Compare them in the scripting guide.

Save and restore sessions after a reboot

tmux sessions are persistent across disconnects, not across reboots: sessions live in memory, so a reboot or kill-server ends them. tmux has no built-in save, but two plugins cover it: tmux-resurrect saves windows, panes, layouts and working directories with Ctrl+b Ctrl+s and restores them with Ctrl+b Ctrl+r, and tmux-continuum saves automatically and can restore when tmux starts. Programs are restarted, not resumed: a running build starts again, unsaved editor buffers are gone. Setup is in the plugins guide.

Common tmux session errors

MessageCauseFix
no server running on /tmp/tmux-1000/defaultNo sessions exist (the server exited)tmux new -s work
error connecting to /tmp/tmux-1000/default (No such file or directory)tmux has not run since boot, or TMUX_TMPDIR differstmux new -s work
can't find session: xWrong or ambiguous nametmux ls, then use the exact name with -t =x
duplicate session: xThe name is takentmux attach -t x or tmux new -A -s x
no sessionstmux attach with nothing to attach totmux new -A -s main
sessions should be nested with care, unset $TMUX to forceRunning tmux inside tmuxtmux switch-client -t x
open terminal failed: not a terminalNo terminal (ssh without -t, cron, a pipe)ssh -t, or new -d in scripts
can't find pane: projectA session name with a dot, like my.projectRename it without the dot

For other errors (lost server, colors, a frozen pane) see tmux troubleshooting.

Frequently asked questions

Do background programs keep running when I detach from tmux?

Yes. When you detach with Ctrl+b d, close the terminal window or lose your SSH connection, the tmux server keeps every program in the session running in the background. Reattach with tmux attach -t name to see them again. They stop only if you kill the session, the last shell exits, the server is killed, or the machine reboots.

What is a tmux session?

A session is a set of windows and panes managed by the tmux server. It keeps running after you detach or disconnect, and you can reattach to it from any terminal on the same machine, including over SSH. The hierarchy is server, then sessions, then windows, then panes.

How do I list tmux sessions?

Run tmux ls (short for tmux list-sessions). For names only, use tmux ls -F '#{session_name}'. Inside tmux, Ctrl+b s shows an interactive list.

How do I create a new named session?

Run tmux new -s name. Add -d to create it in the background without attaching, and -A to attach instead if it already exists.

How do I attach to a tmux session?

Run tmux attach -t name, or tmux a -t name. Plain tmux attach attaches to the most recently used session.

How do I exit a tmux session without killing it?

Detach with Ctrl+b then d, or run tmux detach. Do not type exit: that closes the pane and, in the last pane, the session.

How do I kill a tmux session?

Run tmux kill-session -t name. Inside tmux, press Ctrl+b : and type kill-session to kill the current one. Use -t =name to avoid matching a session whose name only starts with name.

How do I kill all tmux sessions?

Run tmux kill-server. To kill every session except the current one, run tmux kill-session -a; to keep a specific one, tmux kill-session -a -t main.

How do I rename a tmux session?

Press Ctrl+b $ inside tmux, or run tmux rename-session -t old new from any shell.

How do I switch between sessions without detaching?

Press Ctrl+b s and choose a session, use Ctrl+b ( and ) for the previous and next session, or run tmux switch-client -t name. tmux 3.8 adds a fuzzy session switcher on Ctrl+b Shift+Tab.

Do tmux sessions survive a reboot?

No. Sessions live in the tmux server's memory. The tmux-resurrect and tmux-continuum plugins save and restore the layout and working directories, and restart programs, after a reboot.

Why does tmux say 'no server running'?

There are no sessions, so there is no server to talk to. It is the normal state after tmux kill-server or after the last session ends. Start a session with tmux new.

Keep learning

Something wrong or out of date on this page? Email hello@tmux.app and we will fix it.