tmux introduction memo#

We will introduce and use tmux, which is a mechanism that allows you to restart a session even if it expires in a Linux environment. We have summarized the installation and minimal operation method.

install#

sudo apt update
sudo apt install -y tmux

Check version:

tmux -V

Operations you should keep at a minimum#

Session operations#

  • Create a new session: tmux

  • Create a new session (with name): tmux new -s mysession

  • Session list: tmux ls

  • Connect to a session: tmux attach -t mysession

  • Connect to session (simple version): tmux a

  • Detach session: Ctrl-b d

  • Exiting a session: exit or Ctrl-d within a session

  • Restart tmux: tmux kill-server

Window operation#

  • Create a new window: Ctrl-b c

  • Switch windows: Ctrl-b n (next) / Ctrl-b p (previous)

  • Rename window: Ctrl-b ,

Pane operations#

  • Pane split: Ctrl-b % (vertical) / Ctrl-b " (horizontal)

  • Switch panes: Ctrl-b o (next pane) / Ctrl-b ; (previous pane)

  • Switch panes: Ctrl-b + arrow keys

  • Maximize pane: Ctrl-b z (press again to restore)

  • Resize pane: Ctrl-b: , resize-pane -D/U/L/R

Note

  • The default key assignments for pane splitting are confusing. For key changes, refer to .tmux.conf settings.

Minimum .tmux.conf settings#

This setting replaces pane splitting operations using and % with more intuitive symbols. Also, the default splitting key is disabled.

Add the following to ~/.tmux.conf:

bind '\' split-window -h   # 横分割
bind - split-window -v     # 縦分割
unbind '"'
unbind %

This setting allows you to:

  • Ctrl-b \\: Split horizontally (left and right)

  • Ctrl-b - : Split vertically (up and down)

You can intuitively understand the direction of division from the shape of the symbol.

summary#

In this article, we introduced the following points:

  • Installing tmux

  • Basic operations of session window panes

  • Minimal key binding improvements with .tmux.conf

Article information

Post date:

2025-05-10

author:

Mr. Takagi