Skip to content

What is Tmux and how to use it?

  • by
  • 3 min read

Tmux is a rather popular terminal multiplexer that serves as an alternative to the GNU Screen. It allows you to start a session and then open multiple windows inside said session which each window occupying the entire screen and can be split into multiple rectangular panes.

It allows users to switch between multiple programs in one terminal and detach or reattach them at will to a different terminal. Tmux sessions are persistent, which means that programs will continue running even if you get disconnected. 

Also read: Mint vs Ubuntu: Linux distro comparison

How to install Tmux?

There are several ways you can install Tmux on different Linux distros.

  • Ubuntu/Debian: sudo apt install tmux
  • CentOS/Fedora: sudo yum install tmux
  • macOS: brew install tmux

Once you’ve installed Tmux on your system, you can launch a session by typing tmux in the terminal and pressing enter. You’ll notice a status line at the bottom of the screen which shows information about the current session. 

All commands in Tmux have a Ctrl+b prefix. To get a complete list of commands, type Ctril+b ? and hit enter.

Also read: How to remove a Directory in Linux?

How to create named Tmux sessions?

Tmux sessions are named numerically by default. However, you can change this and name each session to your liking. This is extremely helpful when you’re dealing with multiple sessions at once. 

tmux new -s sessionName

The above command will launch a new Tmux session with the specified name. 

Also read: How to use SCP command to transfer files in Linux?

How to detach and reattach from Tmux session?

To detach a Tmux session, type Ctrl+b d and hit enter. The program, if any, running in the session will continue running even after you detach from the session.

To get a list of running Tmux sessions, type tmux ls in the terminal, and you’ll get all the information you need about all the currently running Tmux sessions. 

Now to attach to a session, use the following command.

tmux attach-session -t sessionName

Also read: How to rename a branch in Git? Local and Remote

Tmux windows and panes

By default, Tmux creates a single window containing a shell. To create a new window with a shell, type Ctrl+b c and the first available number from zero to nine will be assigned to said window. You’ll be able to see a list of all windows at the bottom of the screen.

Here are some of the most common Tmux commands for managing windows and panes.

Ctrl+b cCreates a new window with a shell
Ctrl+b wChooses a window from a list
Ctrl+b 0Switch to window 0, or any other specified number
Ctrl+b ,Renames the current window
Ctrl+b %Splits the current pane horizontally
Ctrl+b “Splits the current pane vertically
Ctrl+b oMove on to the next pane
Ctrl+b ;Toggle between the current and previous pane
Ctrl+b xCloses the current working pane

Tmux customisations

By default, Tmux reads its configuration parameters from the ~/.tmux.conf, provided the file is present. You can modify this file to add colours, improve buffers, customise status lines and whatnot. 

Also read: How to check the list of users in Linux?

Basic Tmux usage

When you’re just starting out with Tmux, here’s the process you should follow. 

  • Type tmux new -s sessionName to start a new session.
  • Run the desired program/programs.
  • Use Ctrl+b d to detach from the session if needed.
  • Reattach to the session as and when required using the tmux attach-session -t sessionName command. 

Also read: How to change password in Linux?


Yadullah Abidi

Yadullah is a Computer Science graduate who writes/edits/shoots/codes all things cybersecurity, gaming, and tech hardware. When he's not, he streams himself racing virtual cars. He's been writing and reporting on tech and cybersecurity with websites like Candid.Technology and MakeUseOf since 2018. You can contact him here: