How to Install and Configure Tmux for Linux

If you constantly switch between terminals and can't find the right window when you need it, consider using a multiplexer. These are programs that allow users to run multiple terminal sessions inside a single window.

Tmux is a popular multiplexer that offers a lot of great features. It makes it easy to run different applications in separate sessions and switch between them easily.

How to Install Tmux in Linux

This tutorial introduces how to install and configure Tmux for Linux machines. Activate a Terminal and use the appropriate installation method for your system.

On Debian-based distributions:

sudo install tmux

On CentOS/REHL:

yum install tmux

To install tmux on Arch Linux:

pacman -S tmux

Once the installation is done, launch a Terminal and type tmux to start a new Tmux session. This command will start a new session inside a window and start the shell. The status bar at the bottom shows information about your current session.

tmux

Using Tmux for the first time

Tmux has many concepts like session, window, pane and hotkey. So beginners often find it very intimidating. However, once you have a good understanding of Tmux, you will feel the effectiveness of this tool much more clearly.

A Tmux session defines the task at hand. Windows allows users to perform different operations within a session. Panels, on the other hand, will allow you to work with separate views within the window.

You can manage all of this via hotkeys in Tmux, a combination of the Tmux prefix followed by a specific key. The default prefix is Ctrl + B .

How to manage sessions in Tmux

Tmux can handle multiple sessions at the same time. This allows developers to switch between different projects easily. You can also create a new session anytime you want.

Refer to the article: How to manage and restore Tmux sessions in Linux for more details.

How to manage windows in Tmux

The Tmux window spans the entire screen and can be divided into multiple panes. Each of these panes will act as a separate virtual Terminal. You can create a new tmux window with Ctrl + B c .

Use Ctrl + B , to rename your Tmux window. It will call the Tmux interpreter. Enter the new window name here.

How to Install and Configure Tmux for Linux Picture 1How to Install and Configure Tmux for Linux Picture 1

Tmux makes switching between different windows easy. Enter the Tmux prefix, followed by the window number. For example, you can quickly switch to a second window with Ctrl + B 2 .

You can also swap Tmux windows. To do this, invoke the interpreter by typing Ctrl + B : and enter the following.

: swap-window -s 1 -t 3

This command switches the first and third windows. You can delete a window once done using Ctrl + B & .

How to Install and Configure Tmux for Linux Picture 2How to Install and Configure Tmux for Linux Picture 2

How to manage panes in Tmux

Up to this point, the article has covered how to use sessions and windows in Tmux. However, things get really interesting once you start using panes. Panels are basically virtual terminals that run inside windows. Users can use them to run several instances of Terminal from a single Tmux window.

You can create horizontal and vertical panes in Tmux. Type Ctrl + B " to split the view horizontally.

How to Install and Configure Tmux for Linux Picture 3How to Install and Configure Tmux for Linux Picture 3

This will split the current window horizontally and open a Terminal in a new window. Use Ctrl + B % to start a vertical pane.

How to Install and Configure Tmux for Linux Picture 4How to Install and Configure Tmux for Linux Picture 4

You can create horizontal and vertical panes at the same time. Use hotkey Ctrl + B o to switch between panes.

Changing the zoom level of a pane allows the user to hide all other panes. This feature comes in very handy when you need to focus on a specific task. Use Ctrl + B z to switch panes. You can close the current pane at any time using the hotkey Ctrl + B x .

How to Install and Configure Tmux for Linux Picture 5How to Install and Configure Tmux for Linux Picture 5

How to Configure Tmux in Linux

You can configure almost any aspect of a Tmux installation. However, the article recommends that you start with the basics and move on to more advanced options later.

Configuring Tmux is done by tweaking the ~/.tmux.conf file . Use your favorite Linux text editor to edit this file.

vim ~/.tmux.conf

Let's look at some basic configurations. For example, you can change the Tmux prefix from Ctrl + B to Ctrl + A by adding the line below to the tmux.conf file .

set -g prefix C-a unbind C-b

Unbinding the default key allows you to reassign it to another command. So the second line is an example, nothing is required here.

How to Install and Configure Tmux for Linux Picture 6How to Install and Configure Tmux for Linux Picture 6

You can also change the base index of windows and panes from 0 to 1 , which is very intuitive for users who are not comfortable with 0-based indexes.

set -g base-index 1 # starts window numbering from 1 set -g pane-base-index 1 # starts pane numbering from 1

Since Tmux is a Terminal-driven tool, it does not support mouse functions. However, you can easily enable mouse support for Tmux by adding the file below to your configuration.

set -g mouse on

Hope you are succesful.

4.2 ★ | 5 Vote