Back to the cards

tmux new-session

The tmux new-session command (or its shorthand tmux new) is how you create a new tmux session. A session is a persistent workspace — it keeps running even after you close your terminal or disconnect from a remote machine. Everything you do in tmux happens inside a session.

The most important flag is -s, which lets you name your session. Named sessions are far easier to manage when you have several running:

tmux new -s work

This creates a session called "work" and drops you straight into it. You'll notice the green status bar at the bottom — that's tmux telling you you're inside a session. The session name appears in the bottom-left corner.

You can also create a session that starts in a specific directory:

tmux new -s project -c ~/Code/myproject

Or create a session without attaching to it (useful in scripts):

tmux new -d -s background

Try It Now

  1. Open your terminal and run:
    tmux new -s practice
  2. You're now inside a tmux session called "practice"
  3. Run any command — try ls or echo "hello from tmux"
  4. Look at the status bar at the bottom — you'll see [practice] on the left and the window name on the right
  5. To leave (without stopping the session), press Ctrl-b then d — that's the detach shortcut you'll learn next

If tmux isn't installed, you can install it with:

  • macOS: brew install tmux
  • Ubuntu/Debian: sudo apt install tmux
  • Fedora: sudo dnf install tmux
  • Detach from session — Leave this session running in the background so you can come back later
  • tmux attach — Reconnect to a session after detaching
  • tmux list-sessions — See all your running sessions at a glance
Rate this tip