Getting started with Tmux

Default featured post

Tmux stands for terminal multiplexer. It is basically a great tool to divide one terminal to many different virtual terminals which gives capabilities to do tasks such as system administration in parallel. This is particularly useful when you connect to a remote server. Tmux allows you to detach and attach to terminal from wherever you prefer without losing your data. It is more or less like saving your session, though it is not saving because the processes on the Tmux sessions continue to run. For those who are familiar with Screen command, I must say Tmux has more capabilities than Screen and you can do many things easily that are not very easy to do in Screen.

Tmux itself has a very comprehensive man page which covers each and every aspect.

However, for novice users going through all documentation to extract some most used commands might be cumbersome. Additionally, digesting of some commands require more explanation for beginners. Hence, in this post, I explain about the most basic and fundamental commands of Tmux.

Basic concepts

Before starting going through installation process and the rest of story, I decided to explain slightly about the basic Tmux terminologies and structure.

  • Tmux session is container or superset that can contains multiple windows
  • Tmux window is a subset of session and superset of pane. One window can hold multiple panes
  • Tmux pane is the subset of window and smallest unit
  • Attach to session refers to connecting to a Tmux session which is actively running
  • Detach to session refers to disconnect from a Tmux session. Detaching from a session does not interfere running activities
  • Switching to session refers to switch from one Tmux session to another Tmux session
  • Prefix key is a combination of keys that should be pressed before executing shortcut keys. Default prefix key is Ctrl + b


The very first thing you need to do is to install Tmux. For Ubuntu users run following command in terminal,

$ sudo apt-get install tmux

OpenSUSE users need to use Zypper to install Tmux,

$ sudo zypper install tmux

For other Linux distributions, please refer to related documentations on how to install Tmux or search on the Internet.

Tmux commands

Tmux has a wide range of commands, in the following table list of the most basic commands with their description is provided.

tmux newCreates a new Tmux session with no name
tmux new -s "test"Creates a new Tmux session named “test”
tmux attach -t "test"Attaches to Tmux session named “test”
tmux switch -t "test"Switches to a Tmux session named “test”
tmux lsGets a list of available Tmux sessions
tmux kill-session -t "test"Kills a Tmux session named “test”
tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs killKills all Tmux sessions

Tmux shortcuts

Tmux has many keyboard shortcuts which are necessary to learn to be able to efficiently utilize it. List of must know is provided in below table.

Ctrl + b + dDetaches from the current Tmux session
Ctrl + b + oSwitches between panes
Ctrl + b + o (Not release Ctrl key)Replaces panes
Ctrl + b + cCreates a window
Ctrl + b + %Creates a horizontal pane
Ctrl + b + "Creates a vertical pane
Ctrl + b + $Renames the current Tmux session
Ctrl + b + !Breaks the pane out of the window (Makes a separate window out of the pane)
Ctrl + b + !Breaks the pane out of the window (Makes a separate window out of the pane)
Ctrl + b + (0-9)Switches between windows
Ctrl + b + tShows the current time on the Tmux terminal
Ctrl + b + xKills the current pane
Ctrl + b + zToggles zoom state of the current pane
Ctrl + b + Ctrl + Arrow keysResizes the active pane