DEV Community

Osaigbovo dil Omere
Osaigbovo dil Omere

Posted on

tmux Is Not as Complicated as It Looks (Part 1)

I was doing something embarrassing.

Every time I needed a second terminal, I opened a new window. Every time I needed a third, I opened another. By the time I was running something in the background, monitoring logs, and also trying to edit a file, my taskbar looked like a yard sale. I knew tmux existed. I kept putting off learning it because "I will get to it eventually" is the lie I tell myself about every useful tool.

I eventually got to it. Here is what I wish someone had handed me on day one.


What tmux Actually Is

tmux is a terminal multiplexer. That phrase sounds more intimidating than it is. What it means in practice: you get multiple terminals, split panes, and persistent sessions -- all inside one window. If your SSH connection drops, your session keeps running. You reconnect and everything is exactly where you left it.

Think of it like a single organism with multiple active processes running in the background. The window is the organism. Each pane is a separate process. They all share the same environment but operate independently.

That persistence is the part that does not get enough attention. Without tmux, a dropped SSH connection means a dropped process. With tmux, you detach, the session lives on the remote machine, and you reattach when you are ready. Nothing dies.


Installation

On Arch:

sudo pacman -S tmux
Enter fullscreen mode Exit fullscreen mode

On Debian/Ubuntu:

sudo apt install tmux
Enter fullscreen mode Exit fullscreen mode

On Fedora/Rocky Linux:

sudo dnf install tmux
Enter fullscreen mode Exit fullscreen mode

Verify it installed:

tmux -V
Enter fullscreen mode Exit fullscreen mode

You should get something like tmux x.x. If you do, you are ready.

Installing tmux on Ubuntu 24.04 via apt, confirmed with tmux -V showing version 3.4.


The Prefix Key

Everything in tmux starts with the prefix key. By default, that is Ctrl + B. You press the prefix, release it, then press the command key. Not at the same time -- in sequence.

Press Ctrl + B. Let go. Then press whatever comes next.

This trips people up at first. The rhythm is: chord, release, key. Once it is in your fingers it becomes automatic.

A lot of people will tell you to remap the prefix immediately -- usually to Ctrl + A or Ctrl + Space. I am going to tell you not to.

The reason is practical. The moment you remap your prefix, you have created a tmux that only works the way you expect on machines you control. SSH into someone else's box, or sit down at a machine that is not yours, and you are suddenly trying to remember what the default was while something is actively on fire. The default keybindings are documented everywhere, work on every fresh install, and are already in muscle memory for most people who use tmux seriously. Learning them once is cheaper than maintaining a personal config tax across every machine you ever touch.

I used to remap things. I SSH-ed into a machine once and spent the first five minutes recalling which key did what. That was the last time. Now the only remaps I keep are in Hyprland, where the defaults are genuinely unavoidable. Everything else: learn the default, move on.

Ctrl + B is awkward to reach exactly once. After that, your hand knows where to go.


Sessions

A session is the top-level container. Everything lives inside a session. When you start tmux, you are inside a session. When you detach, the session keeps running without you.

Start a named session:

tmux new -s main
Enter fullscreen mode Exit fullscreen mode

A fresh tmux session named

You are now inside a tmux session called main. You will see a status bar at the bottom of your screen. That bar is how you know you are inside tmux.

Detach from a session (session keeps running in the background):

prefix + d
Enter fullscreen mode Exit fullscreen mode

List all running sessions:

tmux ls
Enter fullscreen mode Exit fullscreen mode

Reattach to a session by name:

tmux attach -t main
Enter fullscreen mode Exit fullscreen mode

Switch between sessions without leaving tmux:

prefix + s
Enter fullscreen mode Exit fullscreen mode

This opens a tree view of all your sessions. You can navigate and select with the arrow keys.

Kill a session:

tmux kill-session -t main
Enter fullscreen mode Exit fullscreen mode

Windows

A window is like a tab inside your session. Each window has its own terminal, running its own shell, independent of the others.

Action Keys
New window prefix + c
Next window prefix + n
Previous window prefix + p
List and switch windows prefix + w
Close current window prefix + &

 raw `prefix + w` endraw  opens a tree view of all sessions and windows. The top shows the session (main) and its single window (0:bash). Below, tmux previews each pane in that window. Navigate with arrow keys and press Enter to jump to any window or pane.

Windows are numbered from 0 by default. The status bar shows the list. In Part 2, I will show you how to make them start from 1 instead -- a small thing that makes navigation feel less arbitrary.


Panes

Panes are where the real productivity lives. They split your window into independent sections, each running its own shell, all visible at the same time.

Action Keys
Split horizontally (top/bottom) prefix + "
Split vertically (left/right) prefix + %
Move between panes prefix + arrow key
Resize a pane prefix + Ctrl + arrow key
Zoom a pane to full screen prefix + z
Close current pane prefix + x, then confirm

The zoom shortcut is worth knowing early. When one pane needs your full attention, prefix + z expands it to fill the window. The same shortcut brings the other panes back. Nothing closes. Nothing moves. It just gives you space when you need it.

Three panes in a single tmux window. Top pane spans the full width (prefix +


The Terminology That Will Trip You Up

tmux uses the word window to mean what most applications call a tab. It uses the word pane to mean what most applications call a split.

It is not a mistake. It is just the convention the tool was built with, and it takes about a day to stop fighting it. Once it settles, it makes sense within the tmux mental model. Until then: window = tab, pane = split.


What You Can Actually Do Now

Sessions, windows, panes, the prefix key. That is already enough to stop opening seventeen terminal windows and start working in a single, organised environment.

Part 2 gets into my config: mouse support, indexed windows, status bar, a theme that does not make you unhappy to look at every day. The defaults are functional. The config is where tmux becomes comfortable.

Top comments (0)