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 later attach, list, rename, and cleanup commands target the intended workspace instead of whichever session tmux would choose automatically.

Printing the new session with -P returns the created target name, and list-sessions confirms the same session with its window count and creation time. If the chosen name is already in use, tmux rejects the request so a second create command does not replace or disturb another running session.

Steps to create a tmux session:

  1. 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 with a project directory when the first window should start somewhere other than the current directory.

  2. List the available sessions to confirm that the new session now exists on the tmux server.
    $ tmux list-sessions
    work: 1 windows (created Fri Jun  5 07:50:35 2026)

    Tmux shows the session name, window count, and creation time for each session it knows about.

  3. 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.