Kokil Thapa - Professional Web Developer in Nepal
Freelancer Web Developer in Nepal with 15+ Years of Experience

Kokil Thapa is an experienced full-stack web developer focused on building fast, secure, and scalable web applications. He helps businesses and individuals create SEO-friendly, user-focused digital platforms designed for long-term growth.

tmux: Terminal Multiplexing for Engineers

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.

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.

tmux Session HierarchySSH Clienttmux ServerSession: prod-appnamed workspaceWindow 0deployWindow 1logsWindow 2mysqlPane APane BPane CPane D
tmux terminal multiplexing layers: one server hosts sessions, each session holds windows, each window splits into panes.

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

ActionKeys (after Ctrl-b)CLI equivalent
Detachdtmux detach
New windowctmux new-window
Next / prev windown / ptmux next-window
Split horizontal"split-window -h
Split vertical%split-window -v
Move between panesarrow keysselect-pane -U/D/L/R
Zoom panezresize-pane -Z
Kill panexkill-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.

Detach and Reattach FlowSSH Connectlaptop to servertmux attachjoin sessionRun Jobdeploy / migrateWi-Fi DropSSH session endsJob Keeps Runninginside tmux serverSSH Reconnecttmux attach againOutputstill there
tmux terminal multiplexing survives SSH drops: the job runs inside the server-side session while your laptop reconnects.

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.

# 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.

CriteriatmuxGNU screen
Default on Ubuntu 24.04Yes, actively maintainedAvailable, less default
Pane splitsNative, flexibleSupported, clunkier
ScriptingRich command setOlder syntax
Status barHighly customisableBasic
Plugin ecosystemTPM, resurrect, continuumLimited
Prefix keyCtrl-b (configurable)Ctrl-a
Learning curveModerateLower 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.

tmux vs screentmuxNative pane splitsTPM pluginsRich status barActive developmentScriptable layoutsPick for new serversscreenLegacy installsCtrl-a prefixMinimal containersOlder runbooksStill works fineKeep for rescue only
tmux terminal multiplexing for engineers outpaces GNU screen on features, plugins, and active maintenance in 2026.

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

  1. SSH to production and attach session prod.
  2. Window 0: run dep deploy production from the deploy user.
  3. Window 1: tail nginx error log in a split pane.
  4. Window 2: watch php artisan queue:work output after symlink swap.
  5. 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.

Deploy Workflow in tmuxsession: prod-laravelPane: dep deployDeployer 7 releasesymlink swapphp-fpm reloadPane: tail logsnginx error.loglaravel.logwatch 500 errorsPane: queue workerphp artisan queue:workverify jobs after deploy
Production tmux layout: deploy command, log tail, and queue worker in one persistent session for Laravel releases.

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 name on shared servers; orphaned sessions pile up.
  • Skipping history-limit in 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.conf in git and symlink it during server provisioning.
  • Prefer tmux over screen on new infrastructure; know screen -R only 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

tmux is a terminal multiplexer that sits between your SSH client and the shell on the server. The multiplexer owns the session; your laptop is just a viewer that can attach and detach. Engineers use it for persistent sessions across SSH drops, multiple panes in one window for logs and deploys, shared pair-debugging sessions, organised layouts per project, and scriptable workflows in CI runbooks. On production Ubuntu boxes I manage for Laravel and WordPress clients, that separation prevents a café Wi-Fi blip from killing a composer install mid-run.

Yes. tmux runs as a server process on the remote machine. Closing your local terminal or losing SSH only detaches your view; commands keep running until you kill them or the server reboots.

Ubuntu 22.04 and 24.04 ship tmux in default repositories, so you rarely need a PPA. Run sudo apt update followed by sudo apt install -y tmux, then confirm with tmux -V. Expect output like tmux 3.4 on Ubuntu 24.04; version numbers vary by distro but core commands stay stable. On fresh VPS setups I install tmux in the same first-login script as UFW, fail2ban, and git. Five minutes upfront prevents hours of lost deploy output when SSH drops mid-job.

Every tmux command uses a prefix key first. The default 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 bindings after Ctrl-b include d to detach, c for a new window, n and p for next and previous window, % for vertical split, double-quote for horizontal split, arrow keys to move between panes, z to zoom a pane, and x to kill a pane. Learn ten bindings and you cover ninety percent of daily use.

Start a named session with tmux new -s myproject. The status bar at the bottom confirms you are inside it. Detach without killing work by pressing Ctrl-b then d. List sessions with tmux ls and reattach with tmux attach -t myproject. When only one session exists, tmux attach alone is enough. I name sessions by project and environment, such as prod-laravel or staging-wp, and document active names in deploy tickets so the next engineer can reattach instantly instead of grepping blindly.

tmux organises work in four layers: one server hosts sessions, each session holds windows, and each window splits into panes. Think of it as tabs and split views, but server-side rather than in your local terminal app. Naming sessions by project and environment saves minutes every week on servers you SSH into regularly. I document this pattern in client handoffs alongside other ops basics. Once you internalise server, session, window, pane, scripting layouts and troubleshooting orphaned sessions become straightforward.

Stock tmux works, but a small ~/.tmux.conf removes friction. I copy a baseline config to every server I manage. Useful settings include bind r to reload config, set -g base-index 1 and pane-base-index 1 so numbering starts at one, set -g mouse on for newcomers, set -g history-limit 50000 so long deploy logs do not scroll off screen, vi-style h/j/k/l pane navigation, pipe and minus keys for horizontal and vertical splits in the current path, a styled status bar, and default-terminal tmux-256color for modern CLI colour output. Reload without restarting sessions using Ctrl-b r after saving the file.

Tmux Plugin Manager, TPM, adds session restore, battery status, and copy helpers. Install it once by cloning the tpm repository into ~/.tmux/plugins/tpm, then add plugin lines to the bottom of ~/.tmux.conf including tmux-plugins/tpm, tmux-resurrect, and tmux-continuum, plus the run command to load TPM. Inside tmux, press prefix then capital I to install plugins. tmux-resurrect saves pane layouts across reboots when you enable continuum. That is useful on staging boxes that restart during kernel patches, though production sessions should still be documented in your ops runbook.

Both solve the same core problem of persistent terminal sessions. tmux is the modern default on Ubuntu 24.04, with native flexible pane splits, a rich scripting command set, a highly customisable status bar, and an active plugin ecosystem through TPM. GNU screen still appears on older hosts and minimal containers, uses Ctrl-a as prefix, and has clunkier pane support. Verdict for 2026: learn tmux first on greenfield Laravel or WordPress servers and standardise it in your runbook. Know one screen command, screen -R, only for legacy rescue boxes where screen is already the norm.

These patterns come from Deployer 7 and GitLab CI pipelines I run on shared EC2 for legal-tech and eCommerce sites. SSH to production and attach a session named for that environment. Window zero runs dep deploy production from the deploy user. A split pane tails the nginx error log. Another watches php artisan queue:work output after the symlink swap. Detach when the deploy finishes; the session stays for the next release. Staging and production never share a session name, because accidental dep deploy to the wrong target hurts badly on real client infrastructure.

Imports and index rebuilds outlive SSH timeouts, so start the job inside a dedicated tmux session rather than a bare shell. Create one with tmux new -s db-import, run your import command such as piping a SQL backup into mysql, then detach with Ctrl-b d and check back later with tmux attach -t db-import. Combine this with mysqldump cron jobs documented in your backup runbook. tmux gives you a live progress view when you reattach; cron gives you the schedule. I use this pattern whenever a migration or restore must survive a laptop sleep or café Wi-Fi drop.

Yes. Multiple SSH clients can attach to one session simultaneously, and everyone sees the same panes and input in real time. That is faster than pasting log fragments into chat when two engineers SSH as the same deploy user. For observers who should not send keystrokes, use tmux attach -t debug -r for read-only mode while someone else drives. I use this on staging servers during incident response. Document the session name in your team wiki or deploy ticket so the second engineer knows exactly which session to join.

Manual splits get old fast. Define layouts in shell scripts and load them on SSH login. Check whether a session already exists with tmux has-session, create one in detached mode if not, send-keys to cd into your app directory and start commands like tail -f on Laravel logs or php artisan queue:work, split panes horizontally and vertically to match your layout, select the primary pane, then attach. Save the script as something like ~/bin/tmux-laravel, chmod +x, and run it after SSH. Three panes open every time with zero manual setup, which mirrors how serious DevOps engineers treat infrastructure-as-habit.

Running tmux inside tmux without renaming sessions makes it unclear which layer owns the job. Forgetting tmux kill-session -t name on shared servers lets orphaned sessions pile up. Skipping history-limit in config means long deploy logs scroll off screen before you can read them. Deploying as root inside tmux is another trap; use a deploy user with sudo only where needed. Not documenting session names in the team wiki forces the next engineer to grep blindly during a hotfix. Write the tmux session name in your deploy ticket every time.

Yes. Install via Homebrew on macOS with brew install tmux, or via apt on WSL2 Ubuntu. Config and key bindings transfer cleanly between local and remote environments.

Share this article

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.

Quick Contact Options
Choose how you want to connect me: