Home » Guides » Tmux on Linux: A Complete Guide on Linux Installations For Debian, Fedora, Ubuntu, RHEL, CentOS, etc.

Tmux on Linux: A Complete Guide on Linux Installations For Debian, Fedora, Ubuntu, RHEL, CentOS, etc.

Remote working has come a long way, and so have related solutions. One such solution is Tmux, which is a terminal multiplexer. In simple words, the tool allows users to create pseudo terminals from a single one, which can be quite useful for running multiple programs within a singular connection. It is very useful when you are running a VM using SSH.

It is quite powerful as users can detach themselves while the terminals will remain active in the background. Given its usefulness, we have created a comprehensive guide on installing Tmux on multiple Linux distributions, using different methods. Take a look.

Table of Contents

What is Tmux?

As we mentioned, Tmux is a terminal multiplexer. But it is saying nothing unless you know what a multiplexer is. So, a terminal multiplexer is a command-line utility. It allows users to manage multiple terminal sessions in a single terminal window without leaving the interface.

Thus, Tmux, as a terminal multiplexer, can create multiple shell sessions in your system. These shell sessions are capable of running separately.

Tmux offers several benefits, especially with remote connections. It can manage multiple terminals on the local machine from a window manager. Furthermore, other features and services are being offered, such as:

tmux, install tmux on linux
Tmux

Features of Tmux

  • Handle multiple sessions at once. 
  • Sessions can be detached and reattached without terminating sessions. 
  • A window management 
  • Windows can be split into multiple resizable sections. 
  • Monitors multiple processes
  • Highly customizable and offers key binding
  • Automatic layouts
  • Panel synchronization 
  • And, script ability

How to Install Tmux On Linux?

Now, let us proceed toward installing Tmux on a Linux system, including all the various Linux distributions. Here’s how:

Method 1. Compiling Tmux From Source

First, we can build Tmux from source, although it is not recommended for beginners. So, you can go to the GitHub website, search for Tmux, download the package, then run the following commands:

cd tmux<VERSION>
./configure
make
sudo make install

Or, you can directly clone it from GitHub:

For this, you need to ensure there are a few dependencies already installed on your system, if not, you need to install them.

Step 1. Start by installing the relevant dependencies:

sudo apt-get install -y libevent-dev libncurses-dev make

Step 2. Then, clone the source file from Git:

wget https://github.com/tmux/tmux/releases/download/3.2a/tmux-3.2a.tar.gz

Step 3. Run the TAR command to package it.

tar xvzf tmux-3.2a.tar.gz

Step 4. Now locate the package:

cd tmux-3.2a

Step 5. Configure the package:

./configure

Step 6. Use MAKE command to install it:

make
sudo make install

Method 2. Using Nixpkgs (Nix Package Manager)

Nix is a package manager and build system for Linux allowing users to focus on declarative packages. It is a unique package management and system configuration tool that makes installing applications much easier on Linux or other UNIX-based systems.

You can also use the Nix package manager to install Tmux. However, you do not need to install NixOS. Simply, fetch the package manager and install it directly.

Solution 1. Global Installation:

If you want the global version run the following command:

sh <(curl -L https://nixos.org/nix/install) --daemon

Solution 2. Local Installation:

If you are only going to use it on a local machine, you can also prefer the following version:

sh <(curl -L https://nixos.org/nix/install) --no-daemon

Once Nixpkgs is installed, you can use it to install Tmux:

nix-env -iA nixpkgs.tmux

Method 3. Install Tmux on Linux using Tarball

Tarball is basically an archive of files, just like ZIP or RAR. Thus, you can unpack Tarball to compile applications.

Similar to the first method, you can incorporate Tarball to compile Tmux from source under two different circumstances, such as:

Case 1. When the Required Libraries are Available in The Native Repository:

Step 1. Run the following command to install the dependencies:

If you are running Debian/Ubuntu:

apt-get install libevent ncurses

If you are running RHEL/CentOS:

yum install libevent ncurses

Step 2. Then Build Tmux:

tar -zxf tmux-*.tar.gz

Step 3. Locate the correct directory

cd tmux-*/YOUR/DIRECTORY

Step 4. Configure and make it:

./configure
make 

Step 5. Finally, install it to compile the package:

sudo make installsudo make install

Case 2. The Required Dependencies are not built Natively

Start by building the dependencies from the source in case they are not available on the respective repositories:

Step 1. First, build libevent:

tar -zxf libevent-*.tar.gz
cd libevent-*/
./configure --prefix=$HOME/local --enable-shared
make 
sudo make install

Step 2. Then, build ncurses

tar -zxf ncurses-*.tar.gz
cd ncurses-*/
./configure --prefix=$HOME/local --with-shared --with-termlib --enable-pc-files --with-pkg-config-libdir=$HOME/local/lib/pkgconfig
make 
sudo make install

Finally, configure Tmux, but be sure to point it to the correct directory:

tar -zxf tmux-*.tar.gz
cd tmux-*/
PKG_CONFIG_PATH=$HOME/local/lib/pkgconfig ./configure --prefix=$HOME/local
make 
sudo make install

Method 4. Install Tmux on Linux Using Docker

Docker is an open-source platform for developing, shipping, and running applications on Linux systems. It allows users to separate applications from native Linux infrastructure so that it can deliver software quickly. Thus, with Docker, you can manage your Linux system and install applications with easy, by relying on OS-level virtualization.

Tmux is also supported as a Docker image. So you can install it using Docker. Here’s how:

Step 1. First, install Docker. For this, you need to set up Docker’s apt repository.

sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

Step 2. Now add it to your APT repository:

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

Step 3. Then install Docker:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Now. you can use either AppImage or a Docker Image to install Tmux:

Solution 1. Using AppImage

Just run the following command to get the latest tmux.appimage build:

curl -s https://api.github.com/repos/nelsonenzo/tmux-appimage/releases/latest \
| grep "browser_download_url.*appimage" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -qi - \
&& chmod +x tmux.appimage

Or, you can build it on your own:

Solution 2. Build it yourself from the source code

git clone https://github.com/nelsonenzo/tmux-appimage.git
cd tmux-appimage
export TMUX_RELEASE_TAG=3.2a
docker build . -t tmux --build-arg TMUX_RELEASE_TAG=$TMUX_RELEASE_TAG 
docker create -ti --name tmuxcontainer tmux bash
docker cp tmuxcontainer:/opt/build/tmux.appimage .
docker rm -f tmuxcontainer
ls -al tmux.appimage

Method 5. Using Native Linux Repositories

Finally, after all these solutions, we have to confess that, Tmux is more likely already available on your Linux distro’s native repository. So, for the most simple of installation, get it directly from there.

Just run the following commands in your system’s command terminal for a quick installation of Tmux:

For Debian or Ubuntu Users:

sudo apt update
sudo apt install tmux

For Fedora Users:

sudo dnf update
sudo dnf install tmux

Those who have openSUSE:

sudo zypper install tmux

For Arch Linux users:

sudo pacman -S tmux -noconfirm

For CentOS/RHEL:

sudo yum update
sudo yum install tmux

That’s all. For more guides on Linux and its various distros, do visit our website.

Gilbert John Avatar