How to Install and Use Tmux

What’s tmux?

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.

Why tmux?

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.

Installation

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, use the commands below to install 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
                    

First Tmux Session

Now that you've completed the installation, type tmux to start the first session:


tmux
                    

Split your pane horizontally by typing:

Ctrl+b then %

Swhich pane by typing:

Ctrl+b then

Ctrl+b then

Detach/Exit session:

Ctrl+b then d

Attach to last session:


tmux a
                    

Now feel free to experiment with the cheat sheet in home page. If you find any missing shortcut, please let me know :D