How to Install, Configure, and Use tmux on Linux

Reading Time: 4 minutes

Working in a Linux terminal often means managing multiple tasks at the same time. You might be monitoring logs, editing configuration files, running long processes, or connecting to several remote servers. Opening multiple terminal windows is one option, but it quickly becomes difficult to manage.

This is where tmux becomes useful. tmux is a terminal multiplexer that allows you to create multiple terminal sessions, split your screen into panes, and keep applications running even after disconnecting from an SSH session. It is lightweight, reliable, and available in virtually every Linux distribution.

This guide covers the installation, initial configuration, and everyday usage of tmux with practical examples that you can immediately apply.

What Is tmux?

tmux (Terminal Multiplexer) allows multiple terminal sessions to exist inside a single terminal window. Instead of opening several terminal applications, you can organize everything into sessions, windows, and panes.

Some of its most useful features include:

  • Persistent terminal sessions;
  • Horizontal and vertical pane splitting;
  • Multiple windows inside one session;
  • Session sharing between users;
  • Easy navigation using keyboard shortcuts;
  • Low resource consumption.

One of the biggest advantages is that processes continue running even if your SSH connection drops.

Installing tmux

Most Linux distributions include tmux in their official repositories:

Ubuntu and Debian

sudo apt update
sudo apt install tmux

Fedora

sudo dnf install tmux

CentOS 8, Rocky Linux, AlmaLinux

sudo dnf install tmux

For older CentOS versions:

sudo yum install tmux

Arch Linux

sudo pacman -S tmux

After installation, verify the installed version:

tmux -V

Example output:

tmux 3.5a

Starting Your First Session

Launch tmux by running:

tmux

A new session starts immediately. You’ll notice a status bar at the bottom of the terminal showing information about the current session.

To create a named session:

tmux new -s development

Naming sessions makes them easier to identify when multiple sessions are active.

Understanding tmux Concepts

tmux is organized into three main components. Let’s talk about them:

Sessions

A session is the top-level container. You can have separate sessions for different projects.

Examples:

tmux new -s webserver
tmux new -s database
tmux new -s monitoring

Windows

Each session contains one or more windows. Think of windows as tabs in a browser.

Create a new window:

Ctrl+b c

Switch between windows:

Ctrl+b n

Go to the previous window:

Ctrl+b p

List all windows:

Ctrl+b w

Panes

Windows can be divided/splited into multiple panes.

Split vertically:

Ctrl+b %

Split horizontally:

Ctrl+b "

Move between panes:

Ctrl+b Arrow Key

Resize a pane:

Ctrl+b Ctrl+Arrow Key

This layout allows you to monitor logs, edit files, and execute commands simultaneously without leaving the current session.

Detaching and Reattaching Sessions

One of tmux’s strongest features is session persistence.

To detach from a running session:

Ctrl+b d

The session continues running in the background.

List available sessions:

tmux ls

Example:

development: 2 windows
monitoring: 1 window

Reconnect to a session:

tmux attach -t development

Or simply:

tmux a

if only one session exists.

Closing Sessions

To terminate the current session:

exit

Repeat until every pane is closed.

Alternatively:

tmux kill-session -t development

To terminate all running sessions:

tmux kill-server

⚠️ Use this carefully because it closes every tmux session currently running.

Basic Configuration

tmux reads its configuration from:

~/.tmux.conf

If the file does not exist, create it:

touch ~/.tmux.conf

Here is a practical starting configuration:

set -g mouse on

setw -g mode-keys vi

set -g history-limit 10000

set -g base-index 1

setw -g pane-base-index 1

bind r source-file ~/.tmux.conf \; display-message "Configuration reloaded"

This configuration provides several improvements:

  • Enables mouse support (you can use your mouse inside the tmux session);
  • Uses Vim-style navigation in copy mode;
  • Increases scrollback history;
  • Starts numbering windows at 1 instead of 0;
  • Allows configuration reloading without restarting tmux.

Reload the configuration after saving:

Ctrl+b r

or

tmux source-file ~/.tmux.conf

Useful Keyboard Shortcuts

Most tmux commands begin with the default prefix:

Ctrl+b

Some shortcuts worth memorizing (or you can use this table as your reference):

ShortcutAction
Ctrl+b cCreate new window
Ctrl+b nNext window
Ctrl+b pPrevious window
Ctrl+b %Split vertically
Ctrl+b “Split horizontally
Ctrl+b ArrowMove between panes
Ctrl+b xClose current pane
Ctrl+b dDetach session
Ctrl+b zToggle pane zoom
Ctrl+b ,Rename window
Ctrl+b $Rename session

Learning just these shortcuts covers most day-to-day workflows.

Running Long Processes Safely

One common use case is running commands that take several hours.

For example:

rsync -av /backup remote:/storage

or

tar -czf archive.tar.gz large_directory/

If your SSH connection drops, these commands continue running inside tmux.

After reconnecting:

ssh server

Then:

tmux attach

Your session returns exactly where you left it.

Working Efficiently with Multiple Panes

A practical layout for system administration might look like this, for example:

  • Pane 1: SSH session
  • Pane 2: htop
  • Pane 3: tail -f /var/log/syslog
  • Pane 4: Text editor

This arrangement allows you to monitor system activity while making configuration changes without switching applications.

Copy Mode

tmux includes its own scrollback buffer.

Enter copy mode:

Ctrl+b [

Navigation becomes similar to Vim when mode-keys vi is enabled.

Useful keys:

  • k — Move up
  • j — Move down
  • / — Search
  • Space — Start selection
  • Enter — Copy selection
  • q — Exit copy mode

This is especially useful when reviewing lengthy command output.

Common Troubleshooting

“command not found”

tmux is probably not installed.

Verify:

which tmux

If nothing is returned, install it using your distribution’s package manager.

Cannot reconnect to a session

Check existing sessions:

tmux ls

If no sessions appear, the previous session was likely closed.

Mouse does not work

Ensure your configuration includes:

set -g mouse on

Reload the configuration afterward.

Cannot Copy Text from tmux to the System Clipboard

A common source of confusion is selecting text inside tmux and discovering that it cannot be pasted into applications such as Notepad, VS Code, or another terminal window.

This usually happens because tmux keeps its own copy buffer, which is separate from your operating system’s clipboard.

If you simply need to copy text to another pane or window inside tmux, use copy mode:

Ctrl+b [

Select the text and press Enter to copy it into tmux’s internal buffer.

To integrate tmux with the system clipboard, install a clipboard utility.

On Debian and Ubuntu:

sudo apt install xclip

or

sudo apt install xsel

On Fedora:

sudo dnf install xclip

Then add the following line to your ~/.tmux.conf:

set -s set-clipboard on

Reload the configuration:

tmux source-file ~/.tmux.conf

Keep in mind that clipboard integration only works when a graphical clipboard is available. If you’re connected to a headless Linux server over SSH, tmux cannot access the clipboard on your local computer. In that case, the simplest solution is often to use your terminal emulator’s own text selection, which usually copies directly to the local clipboard.

Final Thoughts

tmux is one of the most valuable command-line tools available for Linux users, especially system administrators, developers, and anyone who regularly works over SSH. Once you become comfortable with sessions, windows, and panes, it significantly reduces the need to juggle multiple terminal windows while making long-running tasks much safer.

Start with the basic commands covered in this guide, create a simple ~/.tmux.conf, and gradually incorporate more shortcuts into your daily workflow. After a few days of regular use, managing terminal sessions without tmux will likely feel far less efficient.

Similar Posts

  • Working on MySQL Server on Debian 11

    Reading Time: 3 minutesWorking on MySQL Server on Debian 11 is an article that provides some examples of how to create a database, how to create a table, and how to input data into this table. Before anything, I would like to share some articles that we have written: — Installing Linux Debian 11:https://dpcvirtualtips.com/installing-linux-debian-11/ — Installing MySQL Server…

  • Installing Linux CentOS 7

    Reading Time: 5 minutesInstalling Linux CentOS 7 is an article that shows how to install the Linux CentOS 7 step-by-step. First and Foremost, Where Can I download the CentOS 7 installation file? For this article, we are using the CentOS 7. You can download the installation file at the following link:http://mirror.ufam.edu.br/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-DVD-2009.iso About Our Environment So, we are installing…

  • How to Install CentOS 7

    Reading Time: 5 minutesHow to install CentOS 7 is an article that explains, step-by-step, how to install this fantastic operational system. CentOS is a Linux-based distribution, very stable and reliable to use as a server and also as a desktop. The CentOS Project produces two variants: CentOS Linux and CentOS Stream. Here, is a short definition from https://www.centos.org/…

  • GRUB2 Overview

    Reading Time: 3 minutesGRUB2 (GRand Unified Bootloader version 2) is the default boot loader on most Linux flavors. It resides in the Master Boot Record (BIOS systems) or the UEFI System Partition (UEFI systems) and is responsible for: How does GRUB2 work? Basically, we can pop up some GRUB2 stages: Stage 1: Installed in the MBR or EFI…

Leave a Reply

Your email address will not be published. Required fields are marked *