Start your first session
Be attached to a session named learn, with [learn] on the green status line.
tmux new -s name starts tmux and drops you into a session called name. The green bar at the bottom is the status line: [name] on the left is the session, 0:sh* next to it is its one window.
Everything in tmux nests, and each layer has one job:
- server
- runs in the background and holds everything; starts on your first tmux command
- session
- a set of windows; this is what you attach to and detach from
- window
- fills the screen, like a tab
- pane
- a rectangle inside a window running one program, usually a shell
Your terminal is a client talking to the server. The server exits when nothing is left running in it.
Run tmux new.
The screen clears and a green status line appears, reading [0] 0:sh* — session 0, one window named after the shell.
Type exit.
The shell ends, the session with it, and you are back at the plain prompt.
Run tmux new -s learn -n shell.
The status line now reads [learn] 0:shell*. Stay attached.
What the default names are
Without -s the session is called 0, then 1, and so on. Without -n the first window is named after the program running in it, sh here.
Here is what just happened.
tmux new runs new-session. There was no server, so tmux started one, made a session with one window and one pane, and attached your terminal to it. exit ended the shell, then the pane, the window and the session, and the server quit because nothing was left in it. -s and -n only changed the names.
- Start the server if needed, create a session called 0 and attach to ittmux new
- Create a session with a name and attach to ittmux new -s name
- Name the first window instead of naming it after its programtmux new -n name
Go further
- Extra arguments run a program instead of a shell:
tmux new -s monitor -n top top. - A flag and its value can be joined:
-slearnis the same as-s learn. - Running
tmux newwhile already inside tmux is refused. Leaving a session running is detaching, not exiting.
- 1Run it at the plain shell prompt, not inside tmux. If the status line already shows
[0], typeexitfirst. - 2
tmux new -s learnnames the session;-n shellnames its first window. - 3The full command is
tmux new -s learn -n shell.
This is a live terminal. Typing goes to the machine, including Tab. Press Shift and Tab together to move focus back out to the page.
A real terminal, in this tab
Alpine Linux and tmux 3.4 on an x86 emulator. Nothing to install, and no server behind it.
about 15 MB, once
Done when
not started- A session named learn exists on the tmux server— not done yet
- One client (the learner's terminal) is attached to session learn— not done yet