Listing tmux sessions shows which workspaces already exist on the tmux server before you attach, rename, or remove anything. It is the quickest way to see whether a host already has detached shells, editors, logs, or long-running jobs waiting to be resumed.
The list-sessions command asks the running tmux server for every session it manages and prints one line per session. The default output starts with the session name, followed by the current window count and the creation timestamp, so the list doubles as both a target picker and a quick inventory of the workspace behind each name.
The command only works when a tmux server already exists. If no session is running yet, tmux returns a socket error rather than an empty list, and larger session sets are easier to scan when you add a custom -F format or a narrow -f filter.
Related: How to create a tmux session
Related: How to attach to a tmux session
Related: How to rename a tmux session
Related: How to kill a tmux session
Steps to list tmux sessions:
- Run the default session list to see every session currently managed by the tmux server.
$ tmux list-sessions build: 1 windows (created Wed Apr 15 14:36:16 2026) ops: 1 windows (created Wed Apr 15 14:36:16 2026)
The text before the colon is the session name, which is the target used by commands such as attach-session -t, rename-session -t, and kill-session -t. Tmux ls is the short alias if you prefer abbreviated command names.
- Add a custom format when you want the list to emphasize the window count or attached state instead of the default creation timestamp.
$ tmux list-sessions -F '#{session_name}: #{session_windows} windows (#{?session_attached,attached,detached})' build: 1 windows (detached) ops: 1 windows (detached)-F uses tmux format strings, so you can swap in fields such as #{session_created} or #{session_attached} when a script or status check needs different details.
- Filter the list when the server has many sessions and only one target name matters.
$ tmux list-sessions -f '#{==:#{session_name},ops}' ops: 1 windows (created Wed Apr 15 14:36:16 2026)-f keeps the normal output format but only prints sessions whose format expression evaluates true.
- Start or create a session first when tmux reports that no server socket exists yet.
$ tmux list-sessions error connecting to /tmp/tmux-1000/default (No such file or directory)
The numeric directory under /tmp/tmux-UID/ varies by user account, but the message means no tmux server is running yet, so there is nothing to list until a session starts.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
