
September 12, 2026
12 min read
By Kokil Thapa | Last reviewed: September 2026
SSH drops mid-deploy and your long-running job dies with it. That single failure is why tmux: Terminal Multiplexing for Engineers belongs in every production toolkit. tmux keeps shells alive on the server after you disconnect. You split one terminal into panes for logs, queues, and git. If you already use basic commands from our essential Ubuntu terminal commands guide, tmux is the next step for serious server work. This guide covers install, daily keys, config, and real DevOps patterns on Ubuntu servers I maintain for Laravel and WordPress clients.
Ctrl-b d, and reattach later—even after SSH disconnects—so builds, migrations, and log tails keep running safely.What is tmux and why should engineers use terminal multiplexing?
tmux is a terminal multiplexer. It sits between your SSH client and the shell. The multiplexer owns the session. Your laptop is just a viewer that can come and go.
On a production Ubuntu box, that separation matters. I've watched a composer install fail because a café Wi‑Fi blipped. With tmux, the install keeps running. You reattach and read the output.
Engineers reach for tmux when they need:
- Persistent sessions across SSH disconnects
- Multiple panes in one SSH window—logs left, deploy right
- Shared sessions for pair debugging on a remote staging server
- Organised layouts per project—one tmux session per app
- Scriptable workflows via tmux commands in CI or runbooks
tmux pairs naturally with the kind of Linux system administration work I do for Nepali and international clients. You manage PHP-FPM, MySQL, queues, and git from one persistent workspace instead of juggling five terminal tabs.
Think of it as tabs and split views, but server-side. The hierarchy is server → session → window → pane. Naming sessions (prod-laravel, staging-wp) saves minutes every week. I document this pattern in client handoffs alongside other ops basics on my about page workflow notes.
How do you install and start tmux on Ubuntu?
Ubuntu 22.04 and 24.04 ship tmux in the default repositories. Install it once per server. You rarely need a PPA unless you want a bleeding-edge build.
Install tmux
sudo apt update
sudo apt install -y tmux
tmux -V Expect output like tmux 3.4 on Ubuntu 24.04. Version numbers vary by distro. Core commands stay stable. Refer to the upstream tmux project wiki when a flag behaves differently across versions.
Start your first session
tmux new -s myproject You are now inside a named session called myproject. The status bar at the bottom confirms it. Detach without killing work:
# Inside tmux, press: Ctrl-b then d List and reattach:
tmux ls
tmux attach -t myproject Shorthand attach works when only one session exists:
tmux attach On fresh VPS setups—common for domain registration and hosting projects—I install tmux in the same first-login script as UFW, fail2ban, and git. Five minutes upfront prevents hours of lost deploy output later.
How do you create sessions, windows, and panes in tmux?
Every tmux command uses a prefix key first. Default prefix is Ctrl-b. Press prefix, release, then the action key. This two-step pattern avoids clashes with shell shortcuts like Ctrl-a for line start.
Essential key bindings
| Action | Keys (after Ctrl-b) | CLI equivalent |
|---|---|---|
| Detach | d | tmux detach |
| New window | c | tmux new-window |
| Next / prev window | n / p | tmux next-window |
| Split horizontal | " | split-window -h |
| Split vertical | % | split-window -v |
| Move between panes | arrow keys | select-pane -U/D/L/R |
| Zoom pane | z | resize-pane -Z |
| Kill pane | x | kill-pane |
| Command prompt | : | run any tmux command |
Learn ten bindings and you cover ninety percent of daily use. The full reference lives in the tmux manual page.
Scriptable session layouts
Manual splits get old fast. Define layouts in shell scripts and load them on SSH login:
#!/usr/bin/env bash
SESSION="laravel-prod"
tmux has-session -t "$SESSION" 2>/dev/null || {
tmux new-session -d -s "$SESSION" -n deploy
tmux send-keys -t "$SESSION:deploy" 'cd /var/www/app/current' C-m
tmux split-window -h -t "$SESSION:deploy"
tmux send-keys -t "$SESSION:deploy.1" 'tail -f storage/logs/laravel.log' C-m
tmux split-window -v -t "$SESSION:deploy.0"
tmux send-keys -t "$SESSION:deploy.2" 'php artisan queue:work --verbose' C-m
tmux select-pane -t "$SESSION:deploy.0"
}
tmux attach -t "$SESSION" Save as ~/bin/tmux-laravel, chmod +x, and run after SSH. Three panes open every time. No manual setup. This pattern mirrors skills from a solid DevOps engineer learning path for 2026.
Mouse support helps newcomers. Enable it in config (covered next). Scrollback in panes behaves like a normal terminal.
How do you configure tmux for daily DevOps work?
Stock tmux works, but a small ~/.tmux.conf removes friction. I copy a baseline config to every server I manage for sister sites like Notary Kathmandu on shared EC2 infrastructure.
Recommended ~/.tmux.conf
# Reload config: prefix then r
bind r source-file ~/.tmux.conf \; display "Config reloaded"
# Change prefix from Ctrl-b to Ctrl-a (optional; matches GNU screen users)
# set -g prefix C-a
# unbind C-b
# bind C-a send-prefix
set -g base-index 1
setw -g pane-base-index 1
set -g mouse on
set -g history-limit 50000
# Vi-style pane navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Split panes using | and -
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
# Status bar
set -g status-style 'bg=#212529 fg=#f8f9fa'
set -g status-left '#[fg=#09b850] #S '
set -g status-right '#H %Y-%m-%d %H:%M'
# 256-color and truecolor for modern CLI tools
set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm-256color:RGB" Reload without restarting sessions: Ctrl-b r after saving the file. Test colours with htop or a Laravel php artisan command that uses ANSI output.
Plugins and TPM
Tmux Plugin Manager (TPM) adds session restore, battery status, and copy helpers. Install TPM once:
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm Add to the bottom of ~/.tmux.conf:
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
run '~/.tmux/plugins/tpm/tpm' Inside tmux, press prefix + I to install plugins. tmux-resurrect saves pane layouts across reboots if you enable continuum. Useful on staging boxes that restart during kernel patches.
For JSON config snippets you paste into runbooks, our JSON formatter tool catches trailing-comma mistakes before they hit production docs.
tmux vs screen: which terminal multiplexer should engineers choose?
Both tools solve the same core problem. tmux is the modern default on Ubuntu 22/24 servers. GNU screen still appears on older hosts and minimal containers.
| Criteria | tmux | GNU screen |
|---|---|---|
| Default on Ubuntu 24.04 | Yes, actively maintained | Available, less default |
| Pane splits | Native, flexible | Supported, clunkier |
| Scripting | Rich command set | Older syntax |
| Status bar | Highly customisable | Basic |
| Plugin ecosystem | TPM, resurrect, continuum | Limited |
| Prefix key | Ctrl-b (configurable) | Ctrl-a |
| Learning curve | Moderate | Lower for legacy teams |
Verdict: learn tmux first in 2026. Know one screen command—screen -R—for legacy boxes. On greenfield Laravel or WordPress servers, standardise on tmux in your runbook. That single choice reduces context switching across the DevOps skills roadmap teams follow.
How do you use tmux for remote server and deployment workflows?
Theory is cheap. Production patterns are what stick. These workflows come from Deployer 7 + GitLab CI pipelines I run on shared EC2 for legal-tech and eCommerce sites.
Pattern 1: zero-downtime deploy monitoring
- SSH to production and attach session
prod. - Window 0: run
dep deploy productionfrom the deploy user. - Window 1: tail nginx error log in a split pane.
- Window 2: watch
php artisan queue:workoutput after symlink swap. - Detach when deploy finishes; session stays for the next release.
On booking platforms like Adventure Third Pole Trek, I keep a tmux session per environment. Staging and production never share a session name. Accidental dep deploy to the wrong target hurts.
Pattern 2: long database tasks
Imports and index rebuilds outlive SSH timeouts. Start the job inside tmux:
tmux new -s db-import
mysql -u app -p app_db < backup.sql
# Ctrl-b d to detach; check back with tmux attach -t db-import Combine with mysqldump cron jobs documented in your backup runbook. tmux gives you a live progress view. Cron gives you the schedule.
Pattern 3: pair debugging
Two engineers SSH as the same deploy user. Both attach to tmux attach -t debug. Each sees the same panes in real time. Faster than pasting log fragments into chat. Set read-only mode for observers:
tmux attach -t debug -r Pattern 4: sync tmux config across servers
Store dotfiles in git. Symlink on each VPS during provisioning:
ln -sf ~/dotfiles/tmux.conf ~/.tmux.conf Match this with the same PHP-FPM and Apache baseline across sister sites. Consistency beats memorising per-server quirks. See the broader DevOps learning path for how dotfiles fit into infrastructure-as-habit.
Common mistakes to avoid
- Running tmux inside tmux without renaming sessions—you lose track of which layer owns the job.
- Forgetting
tmux kill-session -t nameon shared servers; orphaned sessions pile up. - Skipping
history-limitin config; long deploy logs scroll off screen. - Deploying as root inside tmux; use a deploy user with sudo only where needed.
- Not documenting session names in the team wiki; the next engineer greps blindly.
These mistakes show up during testing and optimization audits when nobody can reproduce how a hotfix was applied. Write the tmux session name in your deploy ticket.
tmux also complements automation topics like prompt engineering for DevOps engineers. AI can draft your layout scripts. You still attach and verify on the real server.
If you hire for ops work, ask candidates to demo a tmux split and detach. It is a fast signal mentioned in guides on hiring a DevOps engineer in Nepal. Tools like tmux separate engineers who live on servers from those who only deploy via GUI panels.
For Laravel application work itself—queues, Horizon, Octane—tmux is the shell layer, not the app layer. Pair this guide with web development services when you need the application built correctly, not just deployed safely.
Ongoing support and maintenance retainers should include a one-page ops doc listing active tmux sessions per server. Future-you will thank present-you at 2 a.m.
Browse more engineering notes on the blog index, including essential GitHub repositories for developers where tmux plugins and dotfile repos appear regularly. Client teams that adopt tmux report fewer "please rerun the migration" messages—see customer reviews for the full-service delivery pattern.
Key Takeaways
- Install tmux on every Ubuntu server you SSH into; treat it as standard ops tooling, not optional.
- Name sessions by project and environment (
prod-shop,staging-api) and script pane layouts once. - Detach with
Ctrl-b d; jobs survive Wi‑Fi drops, laptop sleep, and closed terminal tabs. - Keep a portable
~/.tmux.confin git and symlink it during server provisioning. - Prefer tmux over screen on new infrastructure; know
screen -Ronly for legacy rescue. - Document active session names in deploy tickets so the next engineer can reattach instantly.
People Also Ask
Does tmux keep running after I close my terminal?
Yes. tmux runs as a server process on the remote machine. Closing your local terminal or losing SSH only detaches your view. The session, windows, panes, and running commands continue until you kill them or reboot the server.
Can multiple people attach to the same tmux session?
Yes. Multiple SSH clients can attach to one session simultaneously. Everyone sees the same panes and input. Use tmux attach -r for read-only access when someone else drives debugging.
How do I kill a tmux session I no longer need?
From inside the session, type exit in every pane until the session closes. From outside, run tmux kill-session -t session-name. List sessions first with tmux ls to confirm the name.
Is tmux available on macOS and WSL?
Yes. Install via Homebrew on macOS (brew install tmux) or apt on WSL2 Ubuntu. Config and key bindings transfer cleanly. Remote production work still happens on Linux, but local practice on macOS or WSL builds muscle memory.
Build reliable server workflows with the right tooling
tmux: Terminal Multiplexing for Engineers is not flashy infrastructure. It is the difference between a deploy that survives a disconnect and one you rerun at midnight. Install it, copy a sane config, script one layout for your stack, and use named sessions on every production box you touch. If you want help standardising deploy runbooks, monitoring, and Linux baselines across your Laravel or WordPress servers, contact us to talk through a practical setup.
Frequently Asked Questions
0 Comments
Leave a comment
Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

