After understanding the architecture, it's time to drive the machine: creating and managing sessions, navigating windows like tabs, and splitting and navigating panes with the prefix key.

In episode 2 we dissected the tmux architecture: the client-server model, the session → window → pane hierarchy, communication over a Unix socket, and how the status bar is rendered. In this episode we start driving the machine: managing the lifecycle of sessions, windows, and panes — the three levels you'll touch every day.
Why does this matter in the real world? When you start work on a production server, you usually create a session named after the task context (e.g. deploy, migrasi, debug-api), open a few windows for the editor, logs, and top, then split panes to monitor several things at once. The create → use → detach → re-attach → destroy cycle is every engineer's daily pattern. You'll do it hundreds of times in your career — so make it automatic.
A session is the unit of persistence: this is what you create, attach, detach, and destroy. Its entire lifecycle can be controlled from the command line, inside tmux, or via scripts.
tmux new -s deploy
tmux new -s migrasitmux new -s <nama> creates a session with an easy-to-recognize name. Descriptive names matter because you'll pick that session again when attaching. If no name is given, tmux assigns sequential numbers (0, 1, ...).
tmux new-session -d -s deploy "sudo systemctl status nginx"The -d (detached) flag creates the session in the background without attaching a client — very useful for bootstrapping a work environment from a script. We'll dig into this automation in episode 11.
To enter an existing session:
tmux attach -t deploy
tmux attach
tmux a -t deploytmux attach without -t attaches to the only running session. tmux a is its shorthand alias.
To temporarily leave a session without closing it: press Ctrl+B then d. You're back at the shell prompt, but all processes inside the session keep running.
Tip
This is the moment most often misunderstood: detach (Ctrl+B then d) is different from exit (Ctrl+D or exit). Detach releases the client from the server; exit closes the shell in the pane — and if that's the last pane, the session dies with it. If you only want to "put work on hold", use detach.
tmux ls
deploy: 2 windows (created Mon Aug 2 08:00:00 2026)
migrasi: 1 windows (created Mon Aug 2 08:05:00 2026)tmux ls (or tmux list-sessions) shows all sessions along with their window counts.
tmux kill-session -t migrasi
tmux kill-servertmux kill-session -t <nama> kills the session and all processes inside it — use it with care. tmux kill-server kills the server along with every session.
Warning
kill-session is not "save and close". It kills the processes inside the panes without warning — like closing a terminal that contains running processes. Make sure no important unfinished work is pending before executing this command.
Each session (and window) has its own working directory. When creating a session, tmux takes the working directory from where you ran tmux new. For explicit control:
tmux new -s proyek -c ~/proyek/web
tmux new-window -c ~/proyek/apiThis matters: an editor window, a log window, and a CLI window can start from different directories without manual cd.
Windows are the "tabs" in a session. Everything is controlled via the prefix key.
| Shortcut | Function |
|---|---|
Ctrl+B then c | Create a new window |
The new window is immediately active with a shell prompt in the session's working directory.
| Shortcut | Function |
|---|---|
Ctrl+B then n | Next window |
Ctrl+B then p | Previous window |
Ctrl+B then 0-9 | Jump directly to window number n |
Ctrl+B then w | Choose a window via an interactive list |
Ctrl+B then l | Back to the last accessed window |
| Shortcut | Function |
|---|---|
Ctrl+B then , | Rename window (type the name, press Enter) |
Ctrl+B then f | Find a window containing text |
Ctrl+B then f is very useful when many windows are open — type a fragment of text shown in the target window, and tmux jumps there.
Tip
Get in the habit of giving windows meaningful names (log, code, top) with Ctrl+B then ,. The status bar shows these names, and navigating a busy session becomes much easier — especially when sharing your screen with a team.
| Shortcut | Function |
|---|---|
Ctrl+B then & | Close window (confirm with y) |
exit in the last pane | Close the window at the same time |
Just like sessions, closing a window terminates the processes in all its panes. tmux asks for confirmation before closing.
Panes are split viewports within a window. This is where tmux offers mouse-free "dual screen".
| Shortcut | Function | Layout |
|---|---|---|
Ctrl+B then % | Vertical split (left-right) | Two panes side by side |
Ctrl+B then " | Horizontal split (top-bottom) | Two stacked panes |
Note: % creates a vertical dividing border (panes left & right), while " creates a horizontal dividing border (panes top & bottom). Both can be combined repeatedly:
Ctrl+B + % Ctrl+B + " Ctrl+B + % di pane kiri
+----------+----------+ +------+------+------+
| a | b | | a | b | c |
| | | | | | |
+----------+----------+ +------+------+------+| Shortcut | Function |
|---|---|
Ctrl+B then panah | Move to the pane in that direction |
Ctrl+B then q | Show pane numbers on screen |
Ctrl+B then z | Zoom one pane to full screen (press again to return) |
Ctrl+B then o | Move to the next pane (rotate) |
Ctrl+B then ! | Promote a pane into its own window (break) |
Ctrl+B then x | Close pane (confirm with y) |
Ctrl+B then q shows each pane's number — very helpful when navigating a complex layout. Ctrl+B then z (zoom) temporarily magnifies one pane: edit a file without distractions, then return to the layout.
| Shortcut | Function |
|---|---|
Ctrl+B then x | Close pane (confirm with y) |
exit inside the pane | Close pane (if it's the last one, the window closes too) |
Note
When a window has only one pane, Ctrl+B then x or exit closes that window. And when there's only one window, closing it closes the session. This chained rule is important — follow the "pane → window → session" path when destroying things.
| Level | Shortcut | Function |
|---|---|---|
| Session | tmux new -s <nama> | Create session |
| Session | tmux attach -t <nama> | Attach session |
| Session | tmux ls | List sessions |
| Session | Ctrl+B then d | Detach |
| Session | tmux kill-session -t <nama> | Destroy session |
| Window | Ctrl+B then c / n / p / 0-9 | Create / next / prev / jump |
| Window | Ctrl+B then , / f / & | Rename / find / close |
| Pane | Ctrl+B then % / " | Split vertical / horizontal |
| Pane | Ctrl+B then panah / q / z | Navigate / numbers / zoom |
| Pane | Ctrl+B then x | Close pane |
tmux new -s latihan, then create 3 windows (Ctrl+B then c three times).Ctrl+B then n / p / 0-3 until it's effortless.Ctrl+B then ,, type the name, Enter.Ctrl+B then %, then Ctrl+B then ", then Ctrl+B then panah to move around.Ctrl+B then z to magnify, press again to return.Ctrl+B then d, then tmux attach -t latihan. The processes stay alive.tmux kill-session -t latihan.exit in the last pane kills the session. If you only want to pause, use detach (Ctrl+B then d), not exit.
Wrong session name in -t. tmux kill-session -t salah fails with can't find session. Check tmux ls first.
Creating a new session when you could just attach. You have a deploy session, but running tmux new -s deploy again actually creates a second session (tmux auto-renames it). If you want to return to old work, always tmux attach -t deploy.
Not naming windows/sessions. The status bar becomes a confusing pile of numbers when the session is busy. Get used to -s <nama> and Ctrl+B then ,.
Confusing split directions. % splits left-right (vertical border), " splits top-bottom (horizontal border). Remember: % is the "tall" split, " is the "wide" split.
Closing a pane without making sure no process is running. Ctrl+B then x kills the process in the pane. Make sure the build/deploy process in that pane is really finished.
In episode 3 you mastered the tmux lifecycle basics: creating and managing sessions (new, attach, ls, detach, kill-session), navigating windows like tabs (c, n/p/0-9, , rename, f find), and splitting and navigating panes (% vertical split, " horizontal split, arrows, z zoom). The create → use → detach → re-attach → destroy cycle is now at your fingertips.
Key points to take away:
Ctrl+B then d) ≠ exit — detach saves, exit destroys.% = vertical split, " = horizontal split — combining them creates complex layouts.Ctrl+B then q shows pane numbers; Ctrl+B then z gives focused zoom.Now you can "live" inside tmux. In episode 4, we'll cover Prefix Key & Keybindings — understanding tmux's keybinding system, viewing and searching shortcuts (Ctrl+B then ?), the basics of bind-key and unbind-key, adding custom keybindings in ~/.tmux.conf, all the way to layered keybinding combinations. Stay excited, because full control of the tmux keyboard will soon be in your hands!