tmux Command
On this page
- What is Linux tmux Command?
- Key Features
- tmux Concepts
- tmux Syntax
- Installation
- Basic tmux Usage
- Essential tmux Key Bindings
- Session Management Examples
- Window Management Examples
- Pane Management Examples
- Practical Use Cases
- Advanced tmux Features
- tmux Configuration
- tmux Scripting and Automation
- Troubleshooting
- tmux vs Other Tools
- Best Practices
- tmux Command Manual / Help
- References
- Related Linux Commands
- Summary

What is Linux tmux Command?
tmux (Terminal Multiplexer) is a powerful command-line tool that allows you to create and manage multiple terminal sessions within a single window. It enables you to run multiple programs simultaneously, switch between them, detach from sessions while keeping them running in the background, and reattach to them later from different locations.
tmux is particularly valuable for remote work, long-running processes, and organizing complex workflows. When you lose your SSH connection, tmux sessions continue running on the server, protecting your work from accidental disconnection.
From the man page:
tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.
Key Features
- Session persistence: Sessions survive network disconnections and system reboots
- Multiple windows: Create multiple terminal windows within a single session
- Window splitting: Split windows into multiple panes for parallel work
- Remote accessibility: Attach to sessions from different locations
- Scriptable: Can be automated and configured extensively
- Resource efficient: Lightweight alternative to GUI terminal emulators
tmux Concepts
Sessions
A session is the top-level container that holds one or more windows. Sessions persist even when you disconnect from them.
Windows
Windows are like tabs in a browser - each window can contain one or more panes with different programs running.
Panes
Panes are divisions within a window that allow you to run multiple programs side-by-side in a single window.
tmux Syntax
tmux [command] [options]
Basic usage patterns:
tmux- Start a new sessiontmux new -s session-name- Create named sessiontmux attach -t session-name- Attach to existing sessiontmux list-sessions- List all sessions
Installation
Ubuntu/Debian
sudo apt update
sudo apt install tmuxCentOS/RHEL/Fedora
sudo yum install tmux # CentOS/RHEL
sudo dnf install tmux # FedoramacOS
brew install tmuxBasic tmux Usage
Starting tmux
Start a new session:
tmuxStart a named session:
tmux new -s developmentStart session with specific window name:
tmux new -s project -n editorKey Bindings Concept
tmux uses a prefix key followed by command keys. The default prefix is Ctrl+B. All tmux commands start with this prefix.
Example: Ctrl+B then D means:
- Press and hold
Ctrl+B - Release both keys
- Press
D
Essential tmux Key Bindings
Session Management
Ctrl+B D- Detach from current sessionCtrl+B :- Enter command modeCtrl+B ?- Show help (list all key bindings)
Window Management
Ctrl+B C- Create new windowCtrl+B N- Switch to next windowCtrl+B P- Switch to previous windowCtrl+B 0-9- Switch to window numberCtrl+B ,- Rename current windowCtrl+B &- Close current window (with confirmation)
Pane Management
Ctrl+B %- Split window vertically (side by side)Ctrl+B "- Split window horizontally (top and bottom)Ctrl+B Arrow Keys- Navigate between panesCtrl+B O- Switch to next paneCtrl+B X- Close current pane (with confirmation)Ctrl+B Z- Toggle pane zoom (maximize/restore)Ctrl+B Space- Toggle pane layouts
Session Management Examples
Creating and Managing Sessions
Create a named session:
tmux new -s webdevList all sessions:
tmux list-sessions
# or shorthand
tmux lsAttach to a session:
tmux attach -t webdev
# or shorthand
tmux a -t webdevAttach to last session:
tmux attachKill a session:
tmux kill-session -t webdevKill all sessions:
tmux kill-serverWorking with Detached Sessions
From within tmux, detach session:
# Press Ctrl+B then DFrom command line, detach all clients:
tmux detach -s webdevWindow Management Examples
Creating and Organizing Windows
Create new window with specific command:
tmux new-window -n logs 'tail -f /var/log/syslog'Create window and run multiple commands:
tmux new-window -n server 'cd /var/www && python -m http.server'Rename current window from within tmux:
# Press Ctrl+B then ,
# Type new name and press EnterMove window to different position:
# From command mode (Ctrl+B :)
move-window -t 3Window Navigation
Switch windows by number:
# Ctrl+B then 0, 1, 2, etc.Switch to last active window:
# Ctrl+B then LFind window by name:
# Ctrl+B then F
# Type window name or part of itPane Management Examples
Creating and Arranging Panes
Split current pane vertically:
# Ctrl+B then %Split current pane horizontally:
# Ctrl+B then "Create complex layout:
# Start with full window
# Split vertically: Ctrl+B %
# Move to left pane: Ctrl+B Left Arrow
# Split horizontally: Ctrl+B "
# Result: Left side has two panes, right side has onePane Navigation and Resizing
Move between panes:
# Ctrl+B then Arrow Keys
# or Ctrl+B then O (cycle through panes)Resize panes:
# Hold Ctrl+B and press Arrow Keys repeatedly
# or Ctrl+B : then resize-pane -L 10 (resize left by 10 units)Swap pane positions:
# Ctrl+B then { (swap with previous pane)
# Ctrl+B then } (swap with next pane)Practical Use Cases
Development Environment
Set up a complete development environment:
#!/bin/bash
# Create development session
tmux new-session -d -s dev -n editor
tmux send-keys -t dev:editor 'vim .' Enter
tmux new-window -t dev -n server
tmux send-keys -t dev:server 'npm start' Enter
tmux new-window -t dev -n logs
tmux send-keys -t dev:logs 'tail -f logs/app.log' Enter
tmux new-window -t dev -n terminal
tmux attach-session -t devSystem Monitoring
Create monitoring dashboard:
tmux new-session -d -s monitor -n system
tmux split-window -h -t monitor:system
tmux split-window -v -t monitor:system.0
tmux split-window -v -t monitor:system.1
tmux send-keys -t monitor:system.0 'htop' Enter
tmux send-keys -t monitor:system.1 'iotop' Enter
tmux send-keys -t monitor:system.2 'tail -f /var/log/syslog' Enter
tmux send-keys -t monitor:system.3 'df -h' Enter
tmux attach-session -t monitorRemote Server Management
Set up server administration session:
tmux new-session -d -s admin -n main
tmux new-window -t admin -n logs 'journalctl -f'
tmux new-window -t admin -n docker 'docker stats'
tmux new-window -t admin -n backup
tmux attach-session -t adminAdvanced tmux Features
Copy Mode
Enter copy mode to scroll and copy text:
# Ctrl+B then [ (enter copy mode)
# Use arrow keys or vim keys (h,j,k,l) to navigate
# Space to start selection
# Enter to copy selection
# Ctrl+B then ] to pasteCommand Mode
Enter command mode for advanced operations:
# Ctrl+B then :
# Type commands like:
list-windows
rename-session newsession
set-option status-bg blueSynchronized Panes
Send commands to all panes simultaneously:
# Ctrl+B then :
setw synchronize-panes on
# Now typing will appear in all panes
# Turn off with: setw synchronize-panes offtmux Configuration
Basic Configuration
Create ~/.tmux.conf:
# Change prefix key to Ctrl+A
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# Enable mouse support
set -g mouse on
# Start window numbering at 1
set -g base-index 1
set -g pane-base-index 1
# Automatically renumber windows
set -g renumber-windows on
# Increase scrollback buffer
set -g history-limit 10000
# Enable vim keys in copy mode
setw -g mode-keys vi
# Fast pane switching
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Split panes with more intuitive keys
bind | split-window -h
bind - split-window -vStatus Bar Customization
Customize status bar appearance:
# Status bar colors
set -g status-bg black
set -g status-fg white
# Show session name, window list, and date
set -g status-left '#[fg=green]Session: #S #[default]'
set -g status-right '#[fg=yellow]%Y-%m-%d %H:%M#[default]'
# Highlight active window
setw -g window-status-current-bg red
setw -g window-status-current-fg whiteReload Configuration
Reload tmux configuration without restarting:
# Add to ~/.tmux.conf
bind r source-file ~/.tmux.conf \; display "Config reloaded!"
# Then use Ctrl+B then R to reloadtmux Scripting and Automation
Session Startup Script
Create automated session setup:
#!/bin/bash
# tmux-dev-setup.sh
SESSION_NAME="development"
# Check if session exists
tmux has-session -t $SESSION_NAME 2>/dev/null
if [ $? != 0 ]; then
# Create session
tmux new-session -d -s $SESSION_NAME -n editor
# Setup editor window
tmux send-keys -t $SESSION_NAME:editor 'cd ~/project && vim' Enter
# Create server window
tmux new-window -t $SESSION_NAME -n server
tmux send-keys -t $SESSION_NAME:server 'cd ~/project && npm start' Enter
# Create testing window with split panes
tmux new-window -t $SESSION_NAME -n test
tmux split-window -h -t $SESSION_NAME:test
tmux send-keys -t $SESSION_NAME:test.0 'cd ~/project && npm test' Enter
tmux send-keys -t $SESSION_NAME:test.1 'cd ~/project' Enter
# Go back to editor window
tmux select-window -t $SESSION_NAME:editor
fi
# Attach to session
tmux attach-session -t $SESSION_NAMETmuxinator
Install tmuxinator for advanced session management:
gem install tmuxinator
# Create project configuration
tmuxinator new myproject
# Start project session
tmuxinator start myprojectTroubleshooting
Common Issues
Session not found
# List all sessions to verify name
tmux ls
# Check if tmux server is running
tmux infoKey bindings not working
# Check current prefix key
tmux show-options -g prefix
# Reset to default configuration
tmux kill-server
tmuxConfiguration not loading
# Verify config file location
ls -la ~/.tmux.conf
# Test configuration
tmux source-file ~/.tmux.confPerformance Issues
Too many sessions consuming memory
# List sessions with details
tmux list-sessions -F "#{session_name}: #{session_windows} windows (created #{session_created_string}) [#{session_width}x#{session_height}]"
# Kill unused sessions
tmux kill-session -t unused-sessionSlow response
# Reduce history limit
set -g history-limit 5000
# Disable mouse support if not needed
set -g mouse offtmux vs Other Tools
tmux vs screen
- tmux: More modern, better pane support, active development
- screen: Older, simpler, available on more systems by default
tmux vs terminal tabs
- tmux: Session persistence, remote access, scriptable
- Terminal tabs: Local only, lost on application close
tmux vs IDE
- tmux: Lightweight, terminal-based, remote-friendly
- IDE: Full GUI, integrated tools, resource-intensive
Best Practices
Session Organization
- Use descriptive session names
tmux new -s project-frontend
tmux new -s monitoring-prod- Organize by project or purpose
# Development sessions
tmux new -s web-dev
tmux new -s api-dev
# Administrative sessions
tmux new -s server-admin
tmux new -s backup-tasks- Use consistent window naming
# Window 0: editor
# Window 1: server
# Window 2: logs
# Window 3: terminalWorkflow Optimization
- Create setup scripts for complex environments
- Use configuration files for consistent behavior
- Learn essential key bindings to improve speed
- Use pane synchronization for multi-server management
tmux Command Manual / Help
We can use man and info command to see the manual page of tmux command. tmux command also have --help option to show list of options.
To open man page for tmux command we can use command below. To exit man or info page you can press q.
man tmuxTo open info page for tmux command we can use command below.
info tmuxTo open help page from tmux command we can run command below.
tmux --helpWithin tmux, get help on key bindings:
# Ctrl+B then ?References
You can find more information about tmux from the following links:
Related Linux Commands
You can read tutorials of related Linux commands below:
Summary
In this comprehensive tutorial, we’ve covered the essential aspects of using tmux as a terminal multiplexer. tmux is an invaluable tool for anyone working with command-line interfaces, especially for remote work and complex development workflows.
Key takeaways:
- tmux provides session persistence that survives network disconnections
- Sessions, windows, and panes offer flexible workspace organization
- Essential key bindings start with Ctrl+B prefix by default
- Configuration files enable extensive customization
- Perfect for remote server management and development environments
- Scripting capabilities allow automated session setup
- Superior to basic terminal tabs for professional workflows
Visit our Linux Commands guide to learn more about using command line interface in Linux.