What is tmux?
Quick Answer
Tmux (Terminal Multiplexer) is a command-line utility that allows you to create multiple terminal sessions within a single window, detach from and reattach to sessions, and split your terminal into multiple panes.
Detailed Explanation
Tmux is a powerful terminal multiplexer that enhances your terminal experience by providing features that go beyond what standard terminal emulators offer. The name "tmux" is a combination of "terminal" and "multiplexer," reflecting its core functionality.
Key features of tmux:
- Session persistence: Detach from sessions and reattach later, even after disconnecting from an SSH connection
- Window management: Create multiple windows (like tabs) within a single terminal instance
- Pane splitting: Divide a window into multiple panes, each running its own shell or command
- Synchronized input: Type commands into multiple panes simultaneously
- Customizability: Extensive configuration options through .tmux.conf file
- Scriptability: Automate complex window layouts and startup sequences
Tmux terminology:
- Session: A collection of windows under a single name
- Window: Similar to tabs in a browser, each containing one or more panes
- Pane: Individual terminal instances within a window
- Prefix key: Default
Ctrl+b
, used before tmux commands
Use cases for tmux:
- Running long processes on remote servers that need to continue after you disconnect
- Managing multiple terminal tasks in a single view (e.g., code editor, build process, server logs)
- Pair programming remotely by sharing a tmux session
- Organizing complex development environments with consistent layouts
- Protecting against network disruptions during SSH sessions
Installation
Install tmux on different platforms:
- macOS:
brew install tmux
- Ubuntu/Debian:
sudo apt install tmux
- CentOS/RHEL:
sudo yum install tmux
Historical Context
Tmux was created by Nicholas Marriott in 2007 as an alternative to GNU Screen, with a cleaner codebase and more features. The name stands for "terminal multiplexer," and it has become an essential tool for system administrators, developers, and power users.