Tmux Moment

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.

The Basics

First we must execute the command tmux, within it we can perform different actions, for these actions we must send commands to tmux, in my case I will use the combination ctrl + b which is the configuration by default after installation:

DescriptionCommand
Split terminal horizontallyctrl + b + "
Split terminal verticallyctrl + b + %
Switch to left panelctrl + b + keys left
Switch to right panelctrl + b + keys right
Switch to panel upctrl + b + keys up
Switch to panel downctrl + b + keys down
See terminal numberctrl + b + q
Jump from one panel to anotherctrl + b + o
Close current panelctrl + b + x
Close the current windowctrl + b + &
Cycle through panel layoutsctrl + b + space
Close current panelctrl + b + x
Help tmuxctrl + b + ?
List all sessionstmux ls
Versiontmux -V

Very Useful Features

A very useful function in tmux is the command mode, which allows us to enter commands that facilitate tasks in a simpler way.

DescriptionCommand
Command modectrl + b + :
Activate panel synchronization:setw synchronize-panes on
Turn off panel sync:setw synchronize-panes off
Resize panel up:resize-pane -U
Resize panel down:resize-pane -D
Resize panel to the left:resize-pane -L
Resize panel to the right:resize-pane -R
Resize panel up 10:resize-pane -U 10
Resize panel down 10:resize-pane -D 10
Resize panel to the left 10:resize-pane -L 10
Resize panel to the right 10:resize-pane -R 10

Share Terminal

It is often necessary to work in the same terminal with different users connected to the same server, tmux allows you to share a terminal with multiple users, you just have to meet some requirements:

  1. The terminal to share must belong to a specific user.
  2. A user must create a new tmux session with a name.
  3. The user must share the name of the new session.

First step, create a new tmux session.

1$ tmux new-session -s fcch

Second step, connect to the new session.

1$ sudo su - USER_NAME
2$ tmux attach-session -t fcch

Some Demos

We execute tmux, we divide into different panels the terminal:

Panel synchronization:

Work with panels and resizes with ctrl + b + space and ctrl + b + q:

References

Translations: