Creating a tmux session gives you a persistent workspace that can keep shells, editors, and long-running commands alive even after you leave the terminal. It is the usual starting point when you want one named place to hold related tmux windows and panes.
The new-session command attaches to the new session by default, but -d creates it in the background so the current shell stays where it is. Giving the session a name with -s makes it easy to list, attach, rename, or remove later without guessing which session is which.
Printing the new session with -P gives immediate confirmation that the server accepted the create request, and list-sessions provides a second check that the session now exists. If the chosen name is already in use, tmux rejects the request so you do not accidentally replace another running session.
Related: How to attach to a tmux session
Related: How to list tmux sessions
Steps to create a tmux session:
- Create the session with a descriptive name and print the created session identifier.
$ tmux new-session -d -s work -P work:
The -d flag keeps the current shell in place instead of attaching immediately, and omitting -d opens the new session in the current terminal.
Add -c /path/to/project when the first window should start in a specific directory rather than the current shell directory.
- List the available sessions to confirm that the new session now exists on the tmux server.
$ tmux list-sessions work: 1 windows (created Wed Apr 15 14:29:37 2026)
Tmux shows the session name, window count, and creation time for each session it knows about.
- Choose a different name when tmux reports that the session already exists.
$ tmux new-session -d -s work duplicate session: work
Session names must be unique on the same tmux server, so reuse a different name or attach to the existing session instead of trying to create it again.
Related: How to rename a tmux session
Related: How to kill a tmux session
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.
