tmux: A Practical Guide to the Terminal Multiplexer for Linux Servers

If you have ever started a long-running command over SSH only to watch a dropped Wi-Fi connection kill the whole process, you already understand the problem tmux was built to solve. tmux is a terminal multiplexer: a single program that lets you run many terminal sessions inside one window, split your screen into panes, and most importantly, keep your work running on the server even after you disconnect. For anyone administering a Linux server, it is one of the highest-leverage tools you can learn.

This guide walks through what tmux is, how to install it, the core concepts you need, the essential keybindings, and a basic configuration to make it your own.

Key Takeaways
tmux is a terminal multiplexer that runs multiple sessions, windows, and panes inside a single terminal.
• Its standout feature is session persistence: detach from a session, disconnect SSH, reconnect later, and your work is still running.
• You interact with tmux through a prefix key (default `Ctrl+b`) followed by a command key.
• Core concepts are sessions, windows (tabs), and panes (splits).
• A short `~/.tmux.conf` file lets you remap keys, enable the mouse, and tune behavior to your taste.

What is tmux and why should you use it?

A terminal multiplexer sits between your terminal and the shell. Instead of one shell tied to one terminal window, tmux gives you a persistent server process that holds your shells, and a client that attaches to it. That layer of indirection is where all the power comes from.

The headline benefits for everyday work and server administration are:

  • Persistent sessions that survive disconnects. Start a task, close your laptop, and reconnect from anywhere — the session keeps running on the server.
  • Multiple windows and panes in one terminal. Edit a config in one pane, tail a log in another, and run commands in a third, all visible at once.
  • Detach and reattach at will. Leave a session running in the background and pick it back up exactly where you left off.

If you have used `screen` before, tmux is the modern successor: similar idea, far more flexible splitting, scripting, and configuration.

How do you install tmux?

tmux is in the default repositories of virtually every Linux distribution, so installation is a one-liner.

On Debian and Ubuntu systems:

“`bash sudo apt update && sudo apt install tmux “`

On RHEL, CentOS, Rocky, or Fedora:

“`bash sudo dnf install tmux “`

On Arch Linux:

“`bash sudo pacman -S tmux “`

Confirm it installed and check the version:

“`bash tmux -V “`

Start your first session simply by typing `tmux`. You will land in what looks like an ordinary shell, but with a status bar along the bottom — that bar is your sign that tmux is running.

What are sessions, windows, and panes?

tmux organizes your work into a clean three-level hierarchy. Understanding it is the key to everything else.

  • A session is a top-level container for your work, usually tied to a project or task. You can have many sessions running at once, named or numbered.
  • A window is like a tab inside a session. Each window fills the screen and can hold one or more panes.
  • A pane is a split region within a window — a single shell. You can split a window horizontally and vertically into as many panes as fit.

Think of it as: a session holds windows, and a window holds panes. You attach to a *session*, switch between *windows*, and move between *panes*.

How does the prefix key work?

Because tmux runs inside a terminal that already has its own shortcuts, it needs a way to know when a keystroke is meant for *it* rather than the shell. That signal is the prefix key, which defaults to `Ctrl+b`.

To send a command to tmux, you press the prefix, release it, then press the command key. For example, to create a new window you press `Ctrl+b` and then `c`. Throughout this guide we write that as `prefix c`.

Many experienced users remap the prefix to `Ctrl+a` because it is easier to reach. We will cover that in the configuration section.

Which tmux keybindings are essential?

Below are the bindings you will reach for daily. Each assumes you press the prefix (`Ctrl+b`) first unless noted.

Action Command / Keybinding
Start a new named session `tmux new -s name`
List all sessions `tmux ls`
Attach to a session `tmux attach -t name`
Detach from current session `prefix d`
Create a new window `prefix c`
Next / previous window `prefix n` / `prefix p`
Jump to window by number `prefix 0`–`9`
Rename current window `prefix ,`
Split pane vertically `prefix %`
Split pane horizontally `prefix “`
Move between panes `prefix` + arrow key
Resize a pane `prefix` + hold arrow key
Close current pane `prefix x`
Enter scroll / copy mode `prefix [`
Show all keybindings `prefix ?`

A few of these deserve emphasis. `prefix d` detaches you cleanly — your session keeps running. `prefix [` drops you into copy mode, where you can scroll back through output with the arrow keys or Page Up, and select text to copy. Press `q` to leave copy mode.

How do you manage tmux sessions?

Session commands are run from your normal shell (not after the prefix), and they are what make tmux indispensable on servers.

Create a named session for a specific task:

“`bash tmux new -s deploy “`

Naming sessions matters once you have more than one running. To see everything currently alive:

“`bash tmux ls “`

You might see output like `deploy: 2 windows (created Sat Jun 20 …)`. To reconnect to that session from any new SSH login:

“`bash tmux attach -t deploy “`

To detach again without stopping anything, press `prefix d`. And to remove a session you no longer need:

“`bash tmux kill-session -t deploy “`

This new/attach/detach loop is the heart of the tmux workflow. Once it becomes muscle memory, you will start every server task inside tmux by default.

The single most valuable thing tmux does for a server administrator is decouple the *lifetime of your work* from the *lifetime of your connection*. With a bare SSH session, your shell and every process in it is a child of that connection — when the connection drops, they die with it (or get suspended in unpredictable ways). Inside tmux, your shells are children of the long-lived tmux server running on the box, not of your SSH session. So you can start a database migration, detach with `prefix d`, physically close your laptop, drive home, SSH back in, run `tmux attach`, and watch the migration finish exactly where it was. You stop fearing flaky connections entirely, because the connection is no longer load-bearing. That one property — survival across disconnects — is what turns “I have to babysit this terminal for two hours” into “I’ll check on it whenever.”

Why is tmux essential on servers?

On a personal laptop, tmux is a convenience. On a remote server, it is closer to a necessity. Server work is full of operations that take a long time and must not be interrupted:

  • Long-running migrations that move or transform large datasets.
  • System updates and package upgrades that can run for many minutes.
  • Builds and compilations of large applications.
  • Bulk file transfers or backups.

Run any of these in a plain SSH session and a network blip can corrupt or abort them halfway. Run them inside tmux and they continue regardless of what your connection does. This is the same job the older `screen` tool performed, but tmux does it with better pane management, easier scripting, and cleaner configuration.


Run resilient server tasks with DarazHost. On a DarazHost VPS or dedicated server with full SSH root access, tmux turns fragile remote sessions into dependable ones. Kick off a migration, package upgrade, or long build, detach with `prefix d`, and let it run — your task survives the disconnect and you reattach whenever it suits you. With reliable SSH connectivity and 24/7 support behind your infrastructure, you get the stable foundation that makes long-running operations safe to leave alone.


How do you customize tmux with .tmux.conf?

tmux reads its configuration from `~/.tmux.conf` in your home directory. Even a handful of lines makes a big difference. Create the file and add a few sensible defaults:

“`bash

unbind C-b set -g prefix C-a bind C-a send-prefix

set -g mouse on

set -g base-index 1 setw -g pane-base-index 1

set -g history-limit 10000

bind r source-file ~/.tmux.conf \; display “Config reloaded” “`

After editing, reload the config without restarting by pressing `prefix r` (if you added the binding above) or by running `tmux source-file ~/.tmux.conf` from a shell.

Two changes here pay off immediately: `set -g mouse on` lets you click between panes and scroll naturally, and remapping the prefix to `Ctrl+a` reduces finger strain. Keep your config in version control or your dotfiles repo so every server feels like home.

Frequently asked questions about tmux

What is the difference between tmux and screen? Both are terminal multiplexers that provide persistent sessions. tmux is the more modern option, with first-class support for splitting windows into panes, a scriptable command interface, and a simpler, more readable configuration file. New projects almost always favor tmux.

Will my tmux sessions survive a server reboot? No. tmux persistence covers disconnects, not reboots — the tmux server process and everything in it stops when the machine restarts. For tasks that must survive reboots, use a service manager such as systemd or a tool like nohup combined with proper logging.

How do I scroll up to see earlier output in tmux? Press the prefix followed by `[` to enter copy mode, then use the arrow keys or Page Up to scroll. Press `q` to exit. If you enable `set -g mouse on` in your config, you can also scroll with the mouse wheel.

Can I run tmux automatically when I log in over SSH? Yes. A common pattern is to add logic to your shell profile that attaches to an existing session or creates one if none exists, for example `tmux attach -t main || tmux new -s main`. This drops you straight into a persistent session on every login.

Does tmux work on macOS and other systems? Yes. tmux runs on macOS (install via Homebrew with `brew install tmux`), the BSDs, and through compatibility layers on Windows such as WSL. The concepts and keybindings are identical across platforms.

About the Author

Leave a Reply