tmux on Linux is one of the tools I rely on most when working on remote servers and managing multiple terminal tasks simultaneously. Instead of opening several terminal windows, I use tmux to organize sessions, split the screen into panes, and keep long-running processes active even after disconnecting from an SSH session.
In day-to-day Linux administration, tmux makes it much easier to monitor logs, edit configuration files, execute maintenance tasks, and work with multiple remote systems from a single terminal window. Its lightweight design and wide availability across Linux distributions make it an essential utility for system administrators and developers alike.
In this guide, I demonstrate how to install, configure, and use tmux on Linux with practical examples. You’ll learn how to create and manage sessions, organize windows and panes, customize the basic configuration, and take advantage of features that improve productivity when working from the command line.
What Is tmux?
tmux (Terminal Multiplexer) allows multiple terminal sessions to exist inside a single terminal window. Instead of opening several terminal applications, you can organize everything into sessions, windows, and panes.
Some of its most useful features include:
- Persistent terminal sessions;
- Horizontal and vertical pane splitting;
- Multiple windows inside one session;
- Session sharing between users;
- Easy navigation using keyboard shortcuts;
- Low resource consumption.
One of the biggest advantages is that processes continue running even if your SSH connection drops. This protects the process from an SSH disconnection, but not from a server reboot, a tmux server termination, or the underlying process itself failing.
Install tmux on Linux
Most Linux distributions include tmux in their official repositories:
Ubuntu and Debian
sudo apt update
sudo apt install tmux
Fedora
sudo dnf install tmux
RHEL, Rocky Linux, AlmaLinux, and CentOS Stream
sudo dnf install tmux
For older CentOS versions:
sudo yum install tmux
Arch Linux
sudo pacman -S tmux
After installation, verify the installed version:
tmux -V
Example output:
tmux 3.5a
Starting Your First Session
Launch tmux by running:
tmux
A new session starts immediately. You’ll notice a status bar at the bottom of the terminal showing information about the current session.
To create a named session:
tmux new -s development
Naming sessions makes them easier to identify when multiple sessions are active.
Understanding tmux Concepts
tmux is organized into three main components. Let’s talk about them:
Sessions
A session is the top-level container. You can have separate sessions for different projects.
Examples:
tmux new -s webserver
tmux new -s database
tmux new -s monitoring
Windows
Each session contains one or more windows. Think of windows as tabs in a browser.
Create a new window:
Ctrl+b c
Switch between windows:
Ctrl+b n
Go to the previous window:
Ctrl+b p
List all windows:
Ctrl+b w
Panes
Windows can be divided or split into multiple panes.
Split into left and right panes:
Ctrl+b %
Split into top and bottom panes:
Ctrl+b "
Move between panes:
Ctrl+b Arrow Key
Resize a pane:
Ctrl+b Ctrl+Arrow Key
This layout allows you to monitor logs, edit files, and execute commands simultaneously without leaving the current session.
Detaching and Reattaching Sessions
One of tmux’s strongest features is session persistence.
To detach from a running session:
Ctrl+b d
The session continues running in the background.
List available sessions:
tmux ls
Example:
development: 2 windows
monitoring: 1 window
Reconnect to a session:
tmux attach -t development
Or simply:
tmux a
if only one session exists.
Closing Sessions
To terminate the current session:
exit
Repeat until every pane is closed.
Alternatively:
tmux kill-session -t development
To terminate all running sessions:
tmux kill-server
⚠️ Use this carefully because it closes every tmux session currently running.
Basic Configuration
tmux reads its configuration from:
~/.tmux.conf
If the file does not exist, create it:
touch ~/.tmux.conf
Here is a practical starting configuration:
set -g mouse on
setw -g mode-keys vi
set -g history-limit 10000
set -g base-index 1
setw -g pane-base-index 1
bind r source-file ~/.tmux.conf \; display-message "Configuration reloaded"
This configuration provides several improvements:
- Enables mouse support (you can use your mouse inside the tmux session);
- Uses Vim-style navigation in copy mode;
- Increases scrollback history;
- Starts numbering both windows and panes at 1 instead of 0;
- Allows configuration reloading without restarting tmux.
Reload the configuration after saving:
Ctrl+b r
or
tmux source-file ~/.tmux.conf
Useful Keyboard Shortcuts
Most tmux commands begin with the default prefix:
Ctrl+b
Some shortcuts worth memorizing (or you can use this table as your reference):
| Shortcut | Action |
|---|---|
| Ctrl+b c | Create new window |
| Ctrl+b n | Next window |
| Ctrl+b p | Previous window |
| Ctrl+b % | Split vertically |
| Ctrl+b “ | Split horizontally |
| Ctrl+b Arrow | Move between panes |
| Ctrl+b x | Close current pane |
| Ctrl+b d | Detach session |
| Ctrl+b z | Toggle pane zoom |
| Ctrl+b , | Rename window |
| Ctrl+b $ | Rename session |
Learning just these shortcuts covers most day-to-day workflows.
Running Long Processes Safely
One common use case is running commands that take several hours.
For example:
rsync -av /backup remote:/storage
or
tar -czf archive.tar.gz large_directory/
Important: tmux protects a process from terminal or SSH disconnection. It does not provide application-level recovery, checkpointing, or persistence across a server reboot.
If your SSH connection drops, these commands continue running inside tmux.
After reconnecting:
ssh server
Then:
tmux attach
Your session returns exactly where you left it.
Working Efficiently with Multiple Panes
A practical layout for system administration might look like this, for example:
- Pane 1: SSH session
- Pane 2:
htop - Pane 3:
tail -f /var/log/syslog - Pane 4: Text editor
This arrangement allows you to monitor system activity while making configuration changes without switching applications.
Copy Mode
Each tmux pane maintains its own history buffer, which can be inspected using copy mode.
Enter copy mode:
Ctrl+b [
Navigation becomes similar to Vim when mode-keys vi is enabled.
Useful keys:
k— Move upj— Move down/— SearchSpace— Start selectionEnter— Copy selectionq— Exit copy mode
This is especially useful when reviewing lengthy command output.
Common Troubleshooting
“command not found”
tmux is probably not installed.
Verify:
which tmux
If nothing is returned, install it using your distribution’s package manager.
Cannot reconnect to a session
Check existing sessions:
tmux ls
If no sessions appear, the previous session was likely closed.
Mouse does not work
Ensure your configuration includes:
set -g mouse on
Reload the configuration afterward.
Cannot Copy Text from tmux to the System Clipboard
tmux maintains its own paste buffers, which are separate from the operating system clipboard.
When you copy text using tmux copy mode:
Ctrl+b [
the selected text is normally stored in a tmux paste buffer.
To inspect the current clipboard behavior:
tmux show -s set-clipboard
Modern tmux versions commonly return:
set-clipboard external
tmux can synchronize copied text with the outside terminal using the OSC 52 terminal escape sequence.
For this to work, the terminal must support clipboard integration and tmux must detect the appropriate terminal capability.
You can check it with:
tmux info | grep 'Ms:'
If the terminal supports clipboard integration correctly, tmux can copy text to the clipboard of the terminal outside the session — including in some SSH workflows.
This does not require installing xclip on every remote server.
Another method is to pipe copied text to an external clipboard utility such as xclip, xsel, wl-copy, or pbcopy, depending on the graphical environment and operating system. That is a separate clipboard integration method and normally requires access to the relevant graphical clipboard.
For remote, headless Linux servers, I generally prefer either:
- OSC 52 when supported by the local terminal; or
- the local terminal emulator’s own text-selection and copy features.
For detailed terminal-specific configuration, consult the official tmux Clipboard documentation.
Where tmux Fits in Daily Linux Administration
tmux becomes particularly valuable when Linux administration involves remote SSH sessions, long-running commands, log monitoring, and several terminal workflows at the same time.
Sessions protect running processes from ordinary terminal disconnections, while windows and panes provide a structured way to organize multiple tasks without opening additional SSH connections.
Starting with a small set of shortcuts and a simple ~/.tmux.conf is usually enough. More advanced configuration can be added gradually as tmux becomes part of your normal administration workflow.
External References
- tmux Manual Page Complete command reference for tmux sessions, clients, windows, panes, key bindings, options, configuration files, and command-line operations.
- tmux Getting Started Guide Official tmux project guide explaining the server and client model, sessions, windows, panes, attaching, detaching, configuration, and common interactive workflows.
- Installing tmux Official installation reference covering Linux distribution packages, dependencies, source builds, and installation methods for platforms including Debian, Ubuntu, Fedora, RHEL, CentOS, Arch Linux, and macOS.
-
tmux Clipboard Integration
Official documentation for tmux copy buffers, OSC 52,
set-clipboard, terminal capabilities, SSH clipboard workflows, and external clipboard utilities. - tmux Advanced Use Advanced reference covering tmux sockets, multiple servers, targets, scripting, custom options, session management, terminal behavior, and more complex configuration.
- tmux Official Source Repository Official tmux project repository containing source code, release information, documentation, development history, and links to current project resources.
