9  Tmux

9.1 Introduction

Tmux, short for terminal multiplexer, is a powerful command-line tool that enables users to manage multiple terminal sessions from a single window. It’s particularly useful for remote work, allowing you to create, detach, and reattach to terminal sessions, keeping your work preserved even after disconnection. Tmux enhances productivity and workflow by providing features like window splitting, session management, and customizable key-bindings, making it an indispensable tool for developers, system administrators, and power users who require robust terminal management.

9.2 Installation

# Installation
apt-get install tmux

# Launch
tmux

9.3 Basic Commands

Press ctrl + b then:

  • c: Create a new terminal in the active tmux session
  • n: Switch between different terminals in the session
  • d: Detach from the tmux session
  • ,: Rename a terminal
  • t: Display the time in a terminal
  • z: Close the tmux session
  • w: Select a terminal interactively

Commands in a Split (press Control + b first)

  • %: Vertical split of the current terminal into two + open a terminal in the new panel
  • ": Horizontal split of the current terminal into two + open a terminal in the new panel
  • o: Switch between split terminals
  • space: Change the visual arrangement of split terminals
  • Alt + (arrow keys): Resize split window
  • !: Convert a split into a standalone terminal
  • q: Display numbers of split terminals
  • :join: Join a standalone terminal into a split Example to add terminal number 3 vertically and for it to take up 50% of the total space: :joinp -v -s 3.0 -p 50
    • -h or -v: horizontally or vertically
    • -s 0.0: terminal 0 and pane 0 (pane if screen split)
    • -p 50: occupy 50% of the window

Commands to type in a standard terminal

  • tmux: Create a session
  • tmux attach: Reattach to the last used session
  • tmux ls: See the list of active tmux sessions
  • tmux attach -t X: Attach to a tmux session where X is the session number