tmux
Overview
The tmux
(Terminal Multiplexer) command creates a terminal session manager that allows multiple terminal sessions to be accessed and controlled from a single terminal. It’s a modern alternative to screen.
Syntax
tmux [options] [command]
Common Options
Option | Description |
---|---|
-2 |
Force 256 colors |
-c file |
Config file |
-f file |
Alternative config |
-L socket |
Socket name |
-S socket |
Socket path |
-u |
UTF-8 mode |
-v |
Verbose logging |
-V |
Show version |
-l |
List sessions |
-s session |
Session name |
-t target |
Target session |
Key Bindings
Command | Action |
---|---|
Ctrl-b c |
Create window |
Ctrl-b n |
Next window |
Ctrl-b p |
Previous window |
Ctrl-b d |
Detach session |
Ctrl-b % |
Split vertical |
Ctrl-b " |
Split horizontal |
Ctrl-b x |
Kill pane |
Ctrl-b & |
Kill window |
Ctrl-b [ |
Copy mode |
Ctrl-b ] |
Paste buffer |
Key Use Cases
- Session management
- Remote work
- Project organization
- Process monitoring
- Pair programming
Examples with Explanations
Example 1: New Session
tmux new -s mysession
Create named session
Example 2: Attach Session
tmux attach -t mysession
Attach to existing session
Example 3: List Sessions
tmux ls
Show running sessions
Common Usage Patterns
Start named:
tmux new -s name
Split window:
Ctrl-b % (vertical) Ctrl-b " (horizontal)
Session management:
tmux list-sessions tmux kill-session -t name
Security Considerations
- Socket permissions
- Session access
- Clipboard security
- Remote access
- Multi-user mode
Additional Resources
Best Practices
- Name sessions
- Use windows
- Configure status
- Custom bindings
- Regular cleanup
Configuration
- ~/.tmux.conf
- Key bindings
- Status line
- Colors/theme
- Plugin system
Troubleshooting
- Session issues
- Color problems
- Key conflicts
- Plugin errors
- Performance