Getting Started with tmux / Chapter 1 — Getting Started with tmux (lessons 1–4) / Lesson 1

What tmux Is: A Server That Keeps Running Behind Your Terminal

Time needed: about 7 min (estimate)

☆ Read later

You can try the opening of this lesson without an account.

Three problems tmux solves

tmux is a terminal multiplexer: a tool that creates many terminals inside one terminal and manages them together. It solves three problems. First, whatever you were running stops when you close the terminal or your SSH connection drops. Second, you want to see your editor, server, and logs at once, but you have only one screen. Third, you rebuild the same arrangement by hand every morning.

Tabs and splits in a terminal app solve the second problem, but not the first or the third. tmux works with the same keys on your own machine and on a server, so what you learn once carries over to any machine you SSH into. In this course we build up a workspace step by step, using work on a small website (the folder ~/site) as our subject.

Sessions, windows, and panes

Inside tmux there are three layers. A session is one piece of work, a window is one full screen inside it, and a pane is one region of a split window. Shells and programs run inside panes. The diagram below shows, ahead of time, the shape we'll build later in this course.

The three layers

server (the tmux process; keeps running after you close the terminal) ├── session site <- one piece of work; survives when you leave │ ├── window 0: editor <- one full screen; you switch between them like tabs │ │ ├── pane 0 <- one region of a split window; each runs its own shell │ │ └── pane 1 │ └── window 1: server │ └── pane 0 └── session notes └── window 0: memo └── pane 0 A client (the terminal you are looking at) attaches to one session and looks inside

Reading the first screen

Type just tmux in a terminal, and a new session is created and you're put inside it. Almost nothing looks different: one status line appears at the bottom. Below is a real capture from a terminal 64 columns wide and 14 rows tall.

Screen

$ [0] 0:tmux* "you.local" 22:05 27-Nov-26

Reading the status line from the left: [0] is the session name (a number starting from 0 if you don't name it), and 0:tmux* means "window 0, named tmux, and * marks the window you're looking at". On the right are the pane title (the host name unless you change it) and the time and date. The window name follows the command running inside, so after a moment it becomes 0:bash* or 0:zsh*.

The server and the client

The first tmux starts one server process in the background. That server owns every session, window, and pane. The terminal you are looking at is a client: it connects to the server through a socket file and merely displays the screen. You can check this from another terminal:

Terminal

$ tmux ls 0: 1 windows (created Fri Nov 27 22:05:35 2026) (attached) $ tmux list-clients -F '#{client_name} #{session_name} #{client_width}x#{client_height}' /dev/ttys000 0 64x14 $ tmux display-message -p 'server pid #{pid}, socket #{socket_path}' server pid 39283, socket /tmp/tmux-501/default

Now let's simply close the terminal window that's showing tmux. Before closing it, we typed echo still-here-1 in the pane. Seen from another terminal, there are now zero clients, but the session is still there and so is the content of the pane. Only the (attached) mark is gone.

Terminal

$ tmux ls 0: 1 windows (created Fri Nov 27 22:05:35 2026) $ tmux list-clients $ tmux capture-pane -p -t 0 | grep -v '^$' $ echo still-here-1 still-here-1 $

Rebuilding the listing as a tree

You can list what the server holds with list-sessions, list-windows, and list-panes. -a means "from every session", and -F lets you choose what to print (Lesson 14). Below, we actually built the shape in the diagram above, captured its pane list, and rebuild it into a three-layer tree with Python. A location is written as session:window.pane.

editor.py

Tab indents. To leave the editor, press Esc, then Tab.

Create a free account to keep reading

With an account you can read the rest of this lesson, take the quiz, and read every free lesson in this course. Lessons you answer correctly are recorded as complete.

Report a problem with this lesson

Log in to send a report.

Keyboard shortcuts

Keys available in a lesson
KeyAction
[ or Alt + ←Go to the previous lesson
] or Alt + →Go to the next lesson
?Open this list
EscClose this list

The keys do not work while the cursor is in a code editor or an input field.