How to Install Tmux

Installing Tmux on Linux
Tmux can be installed on Linux using the package manager specific to your distribution. Below are the installation commands for popular Linux distributions:
Distribution | Command |
---|---|
Debian/Ubuntu | sudo apt update && sudo apt install tmux |
Fedora | sudo dnf install tmux |
CentOS/RHEL | sudo yum install epel-release && sudo yum install tmux |
Arch Linux | sudo pacman -S tmux |
openSUSE | sudo zypper install tmux |
Alpine Linux | sudo apk add tmux |
Installing Tmux on macOS
On macOS, Tmux can be easily installed using Homebrew, a popular package manager for macOS. First, ensure Homebrew is installed, and then run:
1 | brew install tmux |
This command will download and install Tmux along with its dependencies.
Verifying the Installation
After installation, verify that Tmux is correctly installed by checking its version:
1 | tmux -V |
If the installation was successful, this command will output the version number of Tmux.
Basic Usage
To start a new Tmux session, simply run:
1 | tmux |
This will create a new session with a status bar at the bottom of the terminal window.
To detach from the current session (while keeping it running in the background), press Ctrl+b
followed by d
. You can reattach to the session later by running:
1 | tmux attach |
To list all running Tmux sessions, use:
1 | tmux ls |
Advanced Installation (From Source)
If you prefer to install Tmux from source, you can follow these steps:
Install the necessary dependencies (e.g.,
libevent
,ncurses
,gcc
,make
,pkg-config
).Download the latest Tmux source code from the official GitHub repository.
Compile and install Tmux:
bash1
2
3
4tar -zxf tmux-*.tar.gz
cd tmux-*/
./configure
make && sudo make install
This method ensures you have the latest version of Tmux.
Common Issues and Solutions
Dependencies Missing: Ensure you have
libevent
andncurses
installed. For example, on Debian-based systems, run:bash1
sudo apt install libevent-dev libncurses-dev
Static Build Issues: If you encounter issues with static builds, ensure you have the necessary static libraries installed (e.g.,
glibc-static
on RHEL/CentOS).Running from
~/local
: If you install Tmux locally, ensureLD_LIBRARY_PATH
is set to point to the correct library paths.
Conclusion
Tmux is a versatile tool that can significantly improve your terminal workflow. By following the steps outlined in this guide, you can easily install Tmux on your system and start managing multiple terminal sessions efficiently. Whether you’re working on Linux or macOS, the installation process is straightforward and well-supported by package managers.
Happy coding!