Tmux (Terminal Multiplexer) is a tool that allows you to manage multiple command-line sessions within a single terminal window. In practice, it functions as a kind of “window manager” for the terminal, enabling efficient control of multiple panes and sessions.

Why use tmux?

  • Sessions persist in the background — you can detach a tmux session and log out from the server without interrupting running processes. When you log back in, you can reattach the session and continue right where you left off.
  • Multiple windows and panes — with tmux, you can split a single terminal window into several sections, allowing you to run multiple commands, monitor log files, or perform parallel tasks simultaneously.
  • Remote work — tmux is especially useful when working over SSH connections, as it prevents interruptions and data loss caused by dropped connections.
  • Customization and automation — tmux supports versatile keyboard shortcuts, scripts, and configuration files, allowing you to create a working environment perfectly suited to your needs.

 

Install tmux

 

Debian, Ubuntu ja Linux Mint

sudo apt update
sudo apt install tmux

 

AlmaLinux, Oracle Linux ja Rocky Linux

sudo dnf install tmux

If you are using an older version that does not have the dnf package manager, use:

sudo yum install tmux

 

Tmux is started with the command tmux. It obeys on default the keybind Ctrl·B + [command] where the command is for example D which cuts the concurrent session. If you want to fully close tmux we can use the command exit just like in shell in general.

 

Example:

  1. Press tmux’s command prefix (by default Ctrl + b)

  2. Then press c

This opens a new window.

 

 

You can return to Tmux with the command:

$ tmux attach

Frequently used key bind combinations

Ctrl·B + C = opens a new "window".

Ctrl·B + X = kills a "window" (and a program inside it)

Ctrl·B + 0...9 = switch to a windows [number between zero and nine]

Ctrl·B + [ = switch to browse mode where you move with arrow keys and exit with the ESCAPE key.

Ctrl·B + T = time

 

In this case Tmux running on the server doesn't hear key bind commands unless you change them separately its settings to work with other keys. You don't need to do this step as Tmux knows how to forward the command by pressing two times CTRL·B and after that the desired command.

Sessions

 

Tmux's usage doesn't limit only to one session as Tmux server knows how to do multiple concurrent sessions. It's worth your time to give also different sessions their own name with the -s parameter as it will be much easier to distinguish between each other. If you don't give the session its name Tmux will give a number as its name.

tmux new-session -s test

You can see all the sessions with the following command.

$ tmux ls

With the command tmux attach (in a shorter shape tmux a ) lets you always connect to the most recent active session. With the parameter -t you can chose which session you want to stick in.

$ tmux a -t testi

Session gets stopped by switching to the chosen session and stopping all the windows from that session with the command exit or by pressing they key combination Ctrl·B·X in every window. The session can be also closed without directly switching to the session with the following command.

$ tmux kill-session -t testi

 

Was this answer helpful? 11 Users Found This Useful (20 Votes)