Let me paint a picture. It’s a Tuesday afternoon, I’m SSHed into three different servers, running a long database migration on one, tailing logs on another, and editing config files on the third. Without tmux, that means three separate SSH connections, three terminals, and a lot of alt-tabbing. With tmux? One terminal window. One session. Total control.

If you spend any significant time in the terminal — whether you’re a developer, a sysadmin, or just someone who occasionally SSHes into a Raspberry Pi — tmux is one of those tools that, once you learn it, makes you wonder how you ever lived without it.

Let’s fix that. By the end of this guide, you’ll have tmux installed, know the essential commands, and have a workflow that’ll make your terminal sessions feel like a superpower.

Linux terminal window showing bash command line interface for tmux terminal multiplexer tutorial
Image: ZxxZxxZ via Wikimedia Commons (GPL)

What Is tmux and Why Should You Care?

I’ve written before about working in the terminal, like in my Python CLI tutorial and the Git bisect guide. tmux is the next logical step — it makes everything you do in the terminal more efficient. tmux stands for “terminal multiplexer.” Fancy name, simple idea: it takes a single terminal window and turns it into a multi-pane, multi-window workspace that persists even when you close your SSH connection.

Here’s what makes it indispensable:

  • Session persistence — Start a long-running task on a remote server, disconnect, come back later, and your session is exactly where you left it. No more accidental disconnects ruining hours of work.
  • Split panes — Edit code in one pane, run the app in another, tail logs in a third. All visible at the same time.
  • Multiple windows — Each tmux window is like a virtual terminal tab. One session can have multiple windows, each with its own split panes.
  • Keyboard-driven — Once the shortcuts become muscle memory, you’ll navigate faster than any mouse user ever could.

It’s like having a window manager inside your terminal. And it works on any Linux, macOS, or even Windows (through WSL).

Installing tmux

Chances are tmux is already installed on your system. Check with:

tmux -V

If you see a version number, you’re good. If not:

# Ubuntu / Debian
sudo apt install tmux

# macOS (Homebrew)
brew install tmux

# Fedora / RHEL
sudo dnf install tmux

# Arch
sudo pacman -S tmux

I’m running tmux 3.2a on Ubuntu, and everything in this guide applies to versions 2.x and above.

Your First tmux Session

The most basic command starts a new unnamed session:

tmux

You’ll notice a green status bar at the bottom. That’s your tmux indicator. It shows session name, window list, and other info. But more on that later.

To get out, type exit or hit Ctrl+d. But that kills the session. To detach — meaning the session keeps running in the background — press:

Ctrl+b d

That’s the prefix Ctrl+b followed by d. Every tmux command starts with the prefix. It’s the “Hey tmux, listen up!” key combination.

Now you’re back in your regular terminal. To reattach to that session:

tmux attach

And your session is right there, exactly as you left it. This alone is worth the price of admission.

Working with Named Sessions

Unnamed sessions work fine when you only have one, but once you start running multiple projects, naming them is a lifesaver. Always start with a name:

tmux new-session -s myproject

Now if you detach (Ctrl+b d) and come back later, you reattach specifically:

tmux attach -t myproject

List all running sessions:

tmux list-sessions

Kill a session when you’re done:

tmux kill-session -t myproject

I always keep my sessions named after the project or server. It makes reattaching feel natural — like walking back to a desk you never actually left.

Splitting Panes: The Game Changer

Here’s where tmux starts to feel magical. Inside a session, you can split the window into multiple panes:

# Split horizontally (top/bottom)
Ctrl+b "

# Split vertically (left/right)
Ctrl+b %

I use vertical splits constantly: code on the left, terminal output on the right. Horizontal splits are great for having a log viewer at the bottom while working above.

Navigate between panes:

Ctrl+b arrow-key    # Move to pane in that direction
Ctrl+b o            # Cycle through panes
Ctrl+b ;            # Toggle to the last active pane

Resize panes (hold the prefix, then press arrow keys repeatedly):

Ctrl+b Ctrl+arrow-key   # Resize pane by 1 unit
Ctrl+b Alt+arrow-key    # Resize pane by 5 units (tmux 1.8+)

Close a pane with Ctrl+d or type exit.

Here’s my typical setup: I SSH into a server, create a session with tmux new -s deploy-check, split vertically (Ctrl+b %), then in the right pane I split horizontally (Ctrl+b "). Three panes — one for running the deploy, one for watching logs, one for quick commands. All in a single SSH connection.

Managing Windows

If panes are like splits within a view, windows are like tabs. Each window can have its own set of panes.

Ctrl+b c       # Create a new window
Ctrl+b p       # Previous window
Ctrl+b n       # Next window
Ctrl+b 0-9     # Switch to window by number
Ctrl+b w       # Interactive window list (like Alt+Tab)
Ctrl+b ,       # Rename the current window
Ctrl+b &       # Kill the current window

The status bar shows all your windows. I like to keep window 1 for code editing, window 2 for running tests, and window 3 for git operations. Each has its own pane setup, and switching between them takes a fraction of a second.

Copy Mode and Scrolling

One thing that throws new tmux users off: you can’t just scroll with the mouse wheel (well, you can — more on that later). In a default tmux, scrolling requires copy mode:

Ctrl+b [       # Enter copy mode
Page Up/Down   # Scroll
Arrow keys     # Move line by line
/              # Search forward
?              # Search backward
q              # Exit copy mode

In copy mode, you can also select text: press Space to start selection, move with arrow keys, Enter to copy. Then Ctrl+b ] to paste.

It takes some getting used to, but once you learn the search functionality (/ in copy mode), you’ll never want to go back to scrolling through terminal history manually.

Mouse Support (Yes, You Can Use Your Mouse)

If the keyboard-only approach feels overwhelming, enable mouse support. Create or edit ~/.tmux.conf:

set -g mouse on

Then reload tmux:

tmux source-file ~/.tmux.conf

Now you can click to switch panes, drag to resize, scroll with the mouse wheel, and select text. Much friendlier for beginners. As you get comfortable, you’ll likely rely on it less, but having it there is a nice safety net.

Customizing tmux with .tmux.conf

This is where tmux goes from useful to personalized productivity machine. Your ~/.tmux.conf file configures everything. Here’s a minimal setup I’d recommend for anyone starting out:

# Enable mouse
set -g mouse on

# Start window numbering at 1 (not 0)
set -g base-index 1

# Increase scrollback buffer
set -g history-limit 50000

# Use 256 colors
set -g default-terminal "screen-256color"

# Change prefix to Ctrl+a (easier to reach)
# set -g prefix C-a
# unbind C-b
# bind C-a send-prefix

# Reload config
bind r source-file ~/.tmux.conf \; display-message "Config reloaded"

# Status bar styling
set -g status-bg colour235
set -g status-fg white
set -g status-left '#[fg=green]#S '
set -g status-right '#[fg=yellow]%Y-%m-%d %H:%M'

Drop that into ~/.tmux.conf, run tmux source-file ~/.tmux.conf, and your tmux experience immediately improves. The reload binding (Ctrl+b r) is especially handy — edit the config and reload without restarting your session.

Essential tmux Workflows

If you’re already managing servers remotely, you might have found my SSH server hardening guide useful — tmux pairs perfectly with a properly secured SSH setup. And if you’re into monitoring, check out how Prometheus and Node Exporter can give you visibility into what those servers are doing.

1. The Remote Server Setup

SSH into a server, start a session, and run a long task:

ssh myserver
tmux new -s backup-run
./long-backup-script.sh
Ctrl+b d   # Detach, go home, sleep
# Next day:
ssh myserver
tmux attach -t backup-run
# Script is done, output is waiting for you

2. The Development Workspace

tmux new -s myapp
Ctrl+b %   # Split vertically
Ctrl+b "   # Split right pane horizontally
# Pane 0: vim/nano for editing
# Pane 1: npm run dev / python app.py
# Pane 2: git status, quick commands

3. The Log Watcher

tmux new -s logs
Ctrl+b "   # Split horizontally
# Top pane: tail -f /var/log/nginx/access.log
# Bottom pane: tail -f /var/log/nginx/error.log
# Both visible at once, updating in real time

Quick Reference Card

CommandWhat It Does
tmux new -s nameCreate named session
tmux attach -t nameReattach to session
tmux list-sessionsShow all sessions
tmux kill-session -t nameKill a session
Ctrl+b dDetach from session
Ctrl+b %Split vertically
Ctrl+b "Split horizontally
Ctrl+b arrowMove to pane
Ctrl+b cNew window
Ctrl+b 0-9Switch to window
Ctrl+b ,Rename window
Ctrl+b [Enter copy mode (scroll)

Troubleshooting Common Issues

Problem: “open terminal failed: missing or unsuitable terminal”
Fix: Install ncurses-term: sudo apt install ncurses-term

Problem: Colors look wrong or banded
Fix: Add set -g default-terminal "tmux-256color" to .tmux.conf

Problem: Ctrl+b doesn’t work in some applications (like Vim)
Fix: Change the prefix to Ctrl+a (see the config above) or press Ctrl+b twice to send it through.

Problem: “sessions should be nested with care” warning
Fix: You’re running tmux inside tmux. This works but gets confusing fast. Use Ctrl+b for the outer session and a different prefix for the inner one, or just detach the outer one first.

Beyond the Basics

If you’re automating deployments, you’ll find that tmux sessions fit well into a GitHub Actions CI/CD pipeline for remote deployment steps. Long-running deploy jobs? Fire them in a tmux session, detach, and check back later without keeping your laptop on.

Once you’ve got the fundamentals down, tmux has a lot more to offer:

  • tmux scripting — Automate workspace setups with shell scripts that create sessions, windows, and panes programmatically. Useful for project-specific environments.
  • plug-ins — Tools like TPM (tmux Plugin Manager) add CPU usage, weather, git branch info to the status bar, or let you save and restore sessions after a reboot.
  • tmuxinator / teamocil — YAML-based session managers. Define a project workspace in a config file and launch it with a single command.

But start simple. Master the basics first — sessions, panes, windows, and the prefix key. Everything else builds on that foundation.

Bottom Line

tmux is one of those tools that feels awkward for the first hour and indispensable forever after. I’ve been using it daily for years, and it’s saved me more times than I can count — from crashed SSH connections to managing multi-server deployments from a single terminal.

Start with named sessions and vertical splits. Add mouse support if the keyboard shortcuts feel overwhelming at first. Customize the config gradually as you discover what you need. Before you know it, you’ll be splitting panes without thinking and wondering how you ever managed servers without it.

For a deeper dive, the official tmux wiki has everything. But what I’ve covered here is enough to transform your terminal workflow starting today.

Filed under Tech & Gadgets
Last Update: June 13, 2026 by Felix AlterEgo
0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Newest
Oldest Most Voted