Tmux is a terminal multiplexer that enables managing multiple command-line sessions remotely. With Tmux you can start a session on a remote server, launch applications in that session, then detach and reattach from that session later.
Key benefits of using Tmux include:
• Resume remote sessions seamlessly - Detach and reattach sessions as needed, even if disconnected.
• Improved remote interactivity - Keep applications and processes running remotely.
• Advanced session control - Tmux supports multiple windows and panes.
• Enhanced productivity - Manage multiple terminals efficiently from a single terminal.
Tmux is highly recommended when working interactively over SSH. The ability to detach and reattach from remote sessions means you can resume seamlessly even if temporarily disconnected. Tmux also improves workflows by enabling multiplexing terminals, applications, and processes across local and remote machines. Other use cases optimized by Tmux include remote development, DevOps, infrastructure management, and any tasks involving remote terminals or command-line access.
Tmux lets you run tasks persistently on remote box, so you can safely disconnect/detach and reconnect/reattach without interrupting these running tasks. It is powerful, extensible and can save more working time when combined with the shortcuts.
MacOS and most Linux platforms provide binary packages for tmux. Use the command below to install from binary.
#macOS (using Homebrew)
$ brew install tmux
#macOS (using MacPorts)
$ port install tmux
#Debian, Ubuntu
$ apt install tmux
#RHEL or CentOS
$ yum install tmux
#Fedora
$ dnf install tmux
#Arch Linux
$ pacman -S tmux
#openSUSE
$ zypper install tmux
If you need the latest version, first install dependencies manually:
# install Tmux dependencies on Debian
$ apt-get install libevent ncurses libevent-dev ncurses-dev build-essential bison pkg-config
# install Tmux dependencies on RHEL/CentOS
$ yum install libevent ncurses libevent-devel ncurses-devel gcc make bison pkg-config
then install Tmux from source:
git clone https://github.com/tmux/tmux.git
cd tmux
sh autogen.sh
./configure && make
Or just download tmux and install without git cloning
wget https://github.com/tmux/tmux/releases/download/3.3a/tmux-3.3a.tar.gz
tar xzvf tmux-3.3a.tar.gz
cd tmux-3.3a
./configure
make && sudo make install
Verify installed version
tmux -V
Now that you've completed the installation, type tmux to start the first session:
tmux
Split your pane horizontally by typing:
Ctrl+b then %
Note: Ctrl+b is the default prefix key. You can customize this in ~/.tmux.conf file.
Swhich pane by typing:
Ctrl+b then
Ctrl+b then
Detach/Exit session:
Ctrl+b then d
Attach to last session:
tmux a
To change prefix key to Ctrl+a, add the below lines to ~/.tmux.conf:
# change prefix from 'Ctrl-b' to 'Ctrl-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
To change prefix key to Ctrl+Space:
# change prefix from 'Ctrl-b' to 'Ctrl-Space'
unbind C-b
set-option -g prefix C-Space
bind-key C-Space send-prefix
Tmux config changes require reload to be applied, run tmux source-file ~/.tmux.conf
from the terminal, or run source-file ~/.tmux.conf
from Tmux’s command-line mode to reload.
To configure shortcut for quick reload, add the line:
bind r source-file ~/.tmux.conf\; display "Reloaded!"
Now feel free to experiment with the cheat sheet in home page. If you find any missing shortcut, please let me know :D