Quick take: tmux is a terminal multiplexer that lets you run multiple terminals in one SSH session, split your screen into panes, and detach from sessions so they keep running when you close your connection. The prefix key is Ctrl+b.
Introduction
tmux (terminal multiplexer) solves one of the oldest pains of remote server work: when your SSH connection drops, every running process dies. With tmux, your work lives inside a server-side session — not tied to your local terminal — so you can detach, reconnect hours later, and pick up exactly where you left off.
Beyond persistence, tmux lets you split a single terminal into multiple panes and organize work across named windows, all inside one SSH connection. It is the standard tool for senior Linux engineers managing remote servers.
Install tmux
# Ubuntu / Debian
sudo apt update && sudo apt install tmux
# RHEL / CentOS / Rocky Linux
sudo dnf install tmux
# Verify installation
tmux -VSessions
A session is a persistent workspace on the server. You can create named sessions, detach from them, and reattach from any terminal.
# Start a new named session
tmux new-session -s mysession
# Short form
tmux new -s deploy
# List all sessions
tmux ls
# Attach to a named session
tmux attach -t mysession
# Kill a specific session
tmux kill-session -t mysession
# Kill all sessions
tmux kill-serverInside a session, detach at any time with Ctrl+b d. Your processes keep running on the server.
Windows
Windows are like tabs inside a session. Each window runs its own shell and appears in the tmux status bar at the bottom.
# Inside tmux — all via prefix key Ctrl+b:
# Create a new window
Ctrl+b c
# Rename current window
Ctrl+b ,
# Switch to next window
Ctrl+b n
# Switch to previous window
Ctrl+b p
# Switch to window by number (e.g., window 2)
Ctrl+b 2
# List all windows interactively
Ctrl+b wPanes
Panes split the current window into multiple terminal areas you can switch between without leaving the window.
# Split vertically (side by side)
Ctrl+b %
# Split horizontally (top and bottom)
Ctrl+b "
# Move between panes
Ctrl+b [arrow key]
# Swap panes
Ctrl+b { # move current pane left
Ctrl+b } # move current pane right
# Make a pane full-screen (zoom in)
Ctrl+b z
# Close current pane
Ctrl+b x
# Resize pane (hold Ctrl+b, then press arrow repeatedly)
Ctrl+b Ctrl+[arrow key]Essential Keybindings
| Keybinding | Action |
|---|---|
| Ctrl+b d | Detach from session (session keeps running) |
| Ctrl+b c | Create new window |
| Ctrl+b % | Split pane vertically |
| Ctrl+b " | Split pane horizontally |
| Ctrl+b z | Zoom/unzoom current pane |
| Ctrl+b [ | Enter scroll/copy mode |
| Ctrl+b ? | Show all keybindings |
| Ctrl+b t | Show a clock |
| Ctrl+b : | Enter tmux command prompt |
| Ctrl+b $ | Rename current session |
Configuring tmux
tmux reads ~/.tmux.conf on startup. A minimal config that most engineers use:
# ~/.tmux.conf
# Change prefix from Ctrl+b to Ctrl+a (screen-like)
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Enable mouse support
set -g mouse on
# Start window numbering from 1 (easier to reach on keyboard)
set -g base-index 1
setw -g pane-base-index 1
# Increase scrollback buffer
set -g history-limit 10000
# Reload config without restarting
bind r source-file ~/.tmux.conf \; display "Config reloaded!"After editing, reload with Ctrl+b : then type source-file ~/.tmux.conf, or press Ctrl+b r if you added the bind above.
Real-World Workflows
A common pattern when deploying to a server: create a named session per project, split into panes for logs and the shell, and detach when done. Anyone on the team with server access can reattach to the session and see the same state.
# Start a deployment session
tmux new -s deployment
# Split: logs on left, shell on right
Ctrl+b %
# In left pane: tail logs
tail -f /var/log/app/production.log
# Move to right pane
Ctrl+b →
# Run deployment
./deploy.sh
# Detach — leave everything running
Ctrl+b d
# Later, from any terminal:
tmux attach -t deploymentThis pattern eliminates the need for nohup or & for long-running processes during interactive deployments.
Final Thoughts
tmux is one of those tools that feels awkward for the first hour and then becomes essential. Start with sessions and detach/attach, then add pane splits once that muscle memory is built. The configuration file lets you reshape every keybinding to match how you think. For any engineer doing serious remote server work, tmux is non-negotiable.
FAQ: tmux Command in Linux
How do I detach from a tmux session without closing it?+
Press Ctrl+b then d. This detaches your client from the session while leaving it running in the background. All processes inside continue running.
How do I reattach to a detached tmux session?+
Run tmux attach or tmux attach-session -t session_name. If you have multiple sessions, run tmux ls first to list them, then attach to the one you want.
What is the difference between a tmux session, window, and pane?+
A session is the top-level container that holds everything and persists after you disconnect. A window is like a tab inside a session. A pane is a split region inside a window — you can have multiple panes running different commands simultaneously.
How do I split the terminal horizontally and vertically in tmux?+
Press Ctrl+b then % to split vertically (side by side), or Ctrl+b then " to split horizontally (top and bottom). Use Ctrl+b and arrow keys to move between panes.
How do I install tmux on Ubuntu?+
Run sudo apt install tmux. On RHEL/CentOS/Rocky Linux, use sudo dnf install tmux. After install, just type tmux to start your first session.
Need help with Linux servers or infrastructure?
Work directly with Muhammad Irfan Aslam for Linux, Ubuntu, Docker, DevOps, cloud, CI/CD, or infrastructure support.
Hire Me for Support