Using tmux terminal multiplexer

The tmux terminal multiplexer allows us to open multiple terminal windows in the same SSH session and continue the command execution even when we log out of the SSH session. This way we can execute long-running copy commands overnight without keeping the SSH session open.

Install tmux

On CentOS family Linux

yum install tmux

To start tmux and attach to the last session

tmux a

To keep the current session active

To continue the session execution even when you log out of the server, detach from the session before closing the connection. See the commands below.

Commands

To switch to binding mode

ctrl-b

Commands in binding mode

d Detach
% Vertical split
Horizontal split
arrows Move between panes
c Create new pane
p Previous window
n Next window
l Last used window
q Display window numbers
[ Enable scroll with arrow keys or pgup, pgdown. Press Esc or q to return normal mode
x Close the pane (will ask you to press “y” to confirm)

Zooming

cmd-shift + zoom in
cmd-shift – zoom out
cmd-shift 0 (zero) 100% zoom

Shared sessions

tmux -S /tmp/shared_session Start a new shared session
chmod 777 /tmp/shared_session Allow anyone to join your session
tmux -S /tmp/shared_session attach Attach to a shared session

Leave a comment

Your email address will not be published. Required fields are marked *