Tmux (also known as a multiplexer) is the initial tool that I immediately install after setting up a fresh Linux system to manage multiple terminal sessions at once.

This is especially useful when accessing remote systems via SSH, or if you're a DevOps engineer, you'll find it very helpful while working on your project for good workflow.

In this article, I'll guide you through steps to install Tmux on Ubuntu and other Linux distros, and then give a few tips on the usage that I daily use with Tmux.

How to Install and Use Tmux on Ubuntu and Other Linux Distros

Tmux is quite a popular tool and is available in almost all popular Linux distributions, allowing you to directly launch your terminal and use the distribution-specific package manager to install Tmux.

  • On Debian and Ubuntu
  • sudo apt install tmux
  • On RedHat and Fedora
  • sudo dnf install tmux
  • On Arch and Manjaro
  • sudo pacman -S tmux
  • On OpenSUSE
  • sudo zypper i tmux

Usage of Tmux

Once the installation is complete, you can immediately initiate the tmux command in your current shell to start a tmux session.

  • tmux


starting tmux session

When you start a tmux session, a horizontal bar will appear at the bottom, indicating that you are in a tmux session.

To split the windows horizontally, hold Ctrl+b, then press ", and to split the window vertically, hold Ctrl+b, and then press %.

splitting pane horizontally and vertically in tmux

To freely move around the panes, you can hold Ctrl+b and then press the Up, Down, Left, and Right arrow keys.

To create a new Tmux window, hold Ctrl+b and then press c. Later, to rename the new Windows name, hold Ctrl+b and press ,.

creating new window in tmux

To navigate between Tmux windows, hold Ctrl+b, then press n to move forward and p to move backward; the active (or focused) window will be marked with * at the end.

To close the specific window, move into it, hold Ctrl+b, then press k; it will ask you to type Y for yes, so type and press enter to close the window.

To temporarily leave the Tmux session without quitting, hold Ctrl+b, then press d to detach the session.

detach tmux session

Later, to list all the detached Tmux sessions, run:

  • tmux ls


listing all tmux session

When you want to reattach your Tmux session, you can use either one of the commands based on your requirements.

  • It will reattach the most recent deattached Tmux session.
  • tmux a
  • It will reattach the specified Tmux session (in this case, 0).
  • tmux attach-session -t 0

There are a lot more Tmux shortcuts that you can explore; explaining them would complicate the article, so it's better if you manually check out this amazing Tmux cheatsheet for reference.