Docu review done: Mon 03 Jul 2023 17:08:54 CEST

Table of Content

General

tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.

When tmux is started it creates a new session with a single window and displays it on screen. A status line at the bottom of the screen shows information on the current session and is used to enter interactive commands.

A session is a single collection of pseudo terminals under the management of tmux. Each session has one or more windows linked to it. A window occupies the entire screen and may be split into rectangular panes, each of which is a separate pseudo terminal (the pty(4) manual page documents the technical details of pseudo termi‐ nals). Any number of tmux instances may connect to the same session, and any number of windows may be present in the same session. Once all sessions are killed, tmux exits.

Each session is persistent and will survive accidental disconnection (such as ssh(1) connection timeout) or intentional detaching (with the ‘C-b d’ key strokes).

Session Window Pane Tree

As listed mentined above, sessions, windows and panes are nested on into the other. You can imagine the structure as follow:

host/client:
  session:
    window:
      pane: 'commands you execute'

Sample

Later we will prvide a grafical view for this as well

mycomputer:
  session_1:
    window_1:
      pane_1: 'htop'
      pane_2: 'tail -f /var/log/daemon'
    window_2:
      pane_1: 'ssh myuser@remotehost'
      pane_2: 'tcpdump -i any host remotehost'
  session_2:
    window_1:
      pane_1: 'bash'

Configuration

The default configuration is done in ~/.tmux.conf and for gloabl config beneath /etc/tmux.conf.

Multible sessions with different configuraitons

If you want to run different configuration for different tmux sessions, you have to use two additional parameters.

  • -f </path/to/config>: With this one you specify the new configuration
  • -L <new_socket_name>: Is used to use run tmux in a new socket with a new name, if you do not set this it will load your configuration provided with -f in addition.

Sample

$ tmux -f ~/.tmux.conf1
$ tmux -L config2 -f ~/.tmux.conf2
$ tmux -L config3 -f ~/.tmux.conf3

What will happen is the folllowing:

  • Line1: Will start a tmux with your default config + the config ~/.tmux.conf1
  • Line2: Will start a new tmux with the socket named config2 and only loads the config ~/.tmux.conf2
  • Line3: Will do the same as Line2 but with different name and config file

If you want to see some other samples, checkout our ssht documentation

Commands

CommandDescription
tmux new -s <session name>opens new session with name
tmux new -s <session name> -n <windows name>opens new session with name and create windows with name
tmux attach -t <session name>connect to session with name
tmux lsshows open sessions
tmux kill-session -t <session name>kills session

In tmux

The Prefix is by default Ctrl+b which can be reconfigured in your .tmux.conf or of course what ever config you provide to your tmux via parameter with parameter -f All these commands below require the Prefix.

CommandDescription
[opens copy-mode where you can use / and ? for searching
"creats horizontral window part
%creats vertical window poart
~creats horizontal window with htop part
:opens command mode
qshows number of window parts
?displays (+configured) shortcuts
wdisplays all open windows in current session
sdisplays all open session on the same socket

URLs

cheatcheet for tmux