Getting started with

Geeksweb | blog.madadipouya.com Kasra Madadipouya [email protected]

Introduction

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 loosing your data. It is or less like saving your session, though it is not saving because the processes on the Tmux sessions continue to run. For those 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 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 a 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 a subset of window and smallest unit. To understand the concept better, have a look following image :

1 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".

Installation

The very first thing you need to do is to install Tmux. For users run following command in terminal, $ 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.

List of Tmux commands

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

2 Table 1: Command Description tmux new Creates a new session with no name tmux new -s "" Creates a new session name it as "test" tmux attach -t "test" Attaches to Tmux with session name "test" tmux switch -t "test" Switches to a Tmux session named "test" tmux Gets list of available Tmux sessions tmux -session -t "test" Kills a session named "test" tmux ls | : | -d. -f1 | ’print substr(1, 0, length(1)-1)’ | kill Kills all Tmux sessions

Table 2: Shortcut Description Ctrl + b + d Detaches the current Tmux session Ctrl + b + o Switches between panes Ctrl + b + o (Not releasing Ctrl key) Replaces the panes Ctrl + b + Creates a window Ctrl + b + % Creates a horizontal pane Ctrl + b + " Creates a vertical pane Ctrl + b + $ Renames the current session Ctrl + b + ! Breaks the current pane out of the window (Makes a separate window out of the pane) Ctrl + b + (0-9) Switches between windows Ctrl + b + t Shows the current on Tmux terminal Ctrl + b + x Kill the current pane Ctrl + b + z Toggles zoom state of the current pane Ctrl + b + Ctrl + Arrow keys Resizes the active pane

Tmux Shortcuts

Tmux has many keyboard short cuts which are necessary to learn to be able to efficiently utilize it. List of must know is provided in below Table 2.

References

[1] Tmux official website (https://tmux.github.io)

[2] Tmux man page (man tmux)

[3] Tmux Wikipedia (https://en.wikipedia.org/wiki/Tmux)

[4] Tmux cheatsheet (https://gist.github.com/MohamedAlaa/2961058)

[5] Tmux a simple start (http://www.sitepoint.com/tmux-a-simple-start/)

3