Linux tmux screen Guide - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Linux tmux and screen Guide
Complete beginner-friendly guide to tmux and screen on Linux, covering Arch Linux, CachyOS, and other distributions including terminal multiplexing, session management, and remote work.
Table of Contents
- Understanding Terminal Multiplexers
- tmux Installation
- tmux Basics
- tmux Advanced
- screen Installation
- screen Basics
- Troubleshooting
Understanding Terminal Multiplexers
What are Terminal Multiplexers?
Terminal multiplexers allow multiple terminal sessions in one window.
Benefits:
- Multiple sessions: Run several programs simultaneously
- Detach/reattach: Keep sessions running after disconnecting
- Split panes: Divide terminal into multiple areas
- Remote work: Essential for SSH sessions
Common uses:
- SSH sessions: Keep work running after disconnect
- Development: Multiple terminals for coding
- System administration: Monitor multiple services
tmux Installation
Install tmux
Arch/CachyOS:
# Install tmux
sudo pacman -S tmux
Debian/Ubuntu:
sudo apt install tmux
Fedora:
sudo dnf install tmux
Launch tmux
Start tmux:
# Start new session
tmux
# Start named session
tmux new -s mysession
tmux Basics
Key Bindings
Default prefix: Ctrl+b
Basic commands:
- Prefix + c: Create new window
- Prefix + n: Next window
- Prefix + p: Previous window
- Prefix + %: Split vertically
- Prefix + ": Split horizontally
- Prefix + d: Detach session
Sessions
Manage sessions:
# List sessions
tmux ls
# Attach to session
tmux attach -t mysession
# Kill session
tmux kill-session -t mysession
tmux Advanced
Windows and Panes
Window management:
# Create window
Prefix + c
# Rename window
Prefix + ,
# Switch windows
Prefix + 0-9
Pane management:
# Split vertically
Prefix + %
# Split horizontally
Prefix + "
# Switch panes
Prefix + arrow keys
# Resize pane
Prefix + Ctrl + arrow keys
Configuration
Configure tmux:
# Create config
vim ~/.tmux.conf
Common settings:
# Set prefix to Ctrl+a
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Enable mouse
set -g mouse on
# Start windows at 1
set -g base-index 1
screen Installation
Install screen
Arch/CachyOS:
# Install screen
sudo pacman -S screen
Debian/Ubuntu:
sudo apt install screen
Fedora:
sudo dnf install screen
Launch screen
Start screen:
# Start new session
screen
# Start named session
screen -S mysession
screen Basics
Key Bindings
Default prefix: Ctrl+a
Basic commands:
- Prefix + c: Create new window
- Prefix + n: Next window
- Prefix + p: Previous window
- Prefix + ": List windows
- Prefix + d: Detach session
- Prefix + A: Rename window
Sessions
Manage sessions:
# List sessions
screen -ls
# Attach to session
screen -r mysession
# Detach (from inside)
Ctrl+a, d
# Kill session
screen -X -S mysession quit
Troubleshooting
tmux Not Starting
Check installation:
# Check tmux
which tmux
tmux -V
# Install if missing
sudo pacman -S tmux
Session Issues
Recover session:
# List sessions
tmux ls
# Attach to session
tmux attach
# Force attach
tmux attach -d
Summary
This guide covered tmux and screen installation, basic usage, and session management for Arch Linux, CachyOS, and other distributions.
Next Steps
- Terminal Emulators - Terminal applications
- SSH Configuration - SSH setup
- tmux: https://github.com/tmux/tmux
- screen: https://www.gnu.org/software/screen/
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.