Customize Linux Terminal with Tmux

This guide will cover the installation and basic use of Tmux to make your Linux terminal more attractive and interactive.

What is tmx?

tmux parts

Tmux is an alternative GNU screen terminal multiplier. In other words, you can start a Tmux session and then open multiple windows in the same session. Each window occupies the entire screen and can be divided into other parts.

With Tmux, you can easily switch between multiple programs in one terminal, and disconnect and connect them again in another.

Enough Tmox session persistentwhich means that programs running on Tmux will continue to run even if your session is disconnected, and the session will start again once the connection exists automatically.

All commands in Tmux begin with a prefix, which is by default ctrl+b.

Install Tmux

You can easily install Tmux using the distro’s package manager.

Install Tmux on Ubuntu and Debian

sudo apt install tmux

Install Tmux on CentOS and Fedora

sudo yum install tmux

Install Tmux on macOS

brew install tmux

Starting a Tmux session

To start your first Tmux session, just type tmux into your console:


This command will open a new session, create a new window and start a shell in that window.

Once you are in Tmux, you will see a status line at the bottom of the screen showing information about the current session.

You are now running your first Tmux command. For example, to get a list of all available commands, type:

Ctrl+b ?

Tmux session naming

By default, Tmux sessions are named numerically. Sessions have names that are useful when running multiple tmux sessions. To create a new named session, run the command tmux With the following arguments:

tmux new -s session_name

It is always a good idea to choose a descriptive name for the session.

See also  Guide for installing Odoo 12 on CentOS 7

A chapter from a Tmux session

You can disconnect from a Tmux session and return to your normal shell by typing:

Ctrl+b d

Programs running in a Tmux session will continue to run after the session is disconnected.

Re-attach to a Tmux session

To attach a session, you need to find the name of the session. To get a list of sessions currently running, type:

tmux ls

The session name is the first column of the output.

0: 1 windows (created Sat Sep 15 09:38:43 2018) [158x35]
my_debug_session: 1 windows (created Sat Sep 15 10:13:11 2018) [78x35]

As you can see from the output, there are two Tmux sessions running, the first one is named 0 And the second my_debug_session.

As an example to attach to the session 0 You can write:

tmux attach-session -t 0

Works with Tmux Windows and Panes

When you start a new tmux session by default, it creates a single window with a shell.

To create a new window with shell type Ctrl+b cwhich is the first available number from the range 0...9 It will occupy the name of the active session.

A list of all windows is displayed in the status bar at the bottom of the screen.

Here are some of the most popular commands for managing Tmux windows and panels:

  • Ctrl+b c Create a new window (with shell)
  • Ctrl+b w Select a window from the list
  • Ctrl+b 0 Switch to window 0 (by number)
  • Ctrl+b , Rename the current window
  • Ctrl+b % Divide the current part horizontally into two panels
  • Ctrl+b " Divide the current part vertically into two parts
  • Ctrl+b o Go to the next panel
  • Ctrl+b ; Switch between current and previous panels
  • Ctrl+b x Close the current panel
See also  A tutorial on using the Lsmod command (listing Kernel units)

Customization Tmux

When Tmux starts, it reads its configuration parameters from ~/.tmux.conf If the file exists.

The following is an example of the configuration ~/.tmux.conf With a custom status line and some additional options:

sudo nano .tmux.conf
# Improve colors
set -g default-terminal 'screen-256color'

# Set scrollback buffer to 10000
set -g history-limit 10000

# Customize the status line
set -g status-fg  green
set -g status-bg  black

Basic use of Tmux

Here are the most important steps to get started with Tmux:

  1. At the command prompt, type tmux new -s my_sessionAnd the
  2. Run the required program.
  3. Use keychain Ctrl-b + d to disconnect from the session.
  4. Reconnect to a Tmux session by typing tmux attach-session -t my_session.


In this tutorial, you learned how to use Tmux. You can now start creating multiple Tmux windows in one session, split windows by creating new panes, move between windows, separate and resume sessions, and customize your Tmux instances with files .tmux.conf.

To see the tmux manual page, you can type

man tmux

Source link