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:

Description Command
Split terminal horizontally ctrl + b + "
Split terminal vertically ctrl + b + %
Switch to left panel ctrl + b + keys left
Switch to right panel ctrl + b + keys right
Switch to panel up ctrl + b + keys up
Switch to panel down ctrl + b + keys down
See terminal number ctrl + b + q
Jump from one panel to another ctrl + b + o
Close current panel ctrl + b + x
Close the current window ctrl + b + &
Cycle through panel layouts ctrl + b + space
Close current panel ctrl + b + x
Help tmux ctrl + b + ?
List all sessions tmux ls
Version tmux -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.

Description Command
Command mode ctrl + 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: