Tmux is a terminal multiplexer. This is the kind of tools where you don’t know that you need. This tool is useful when you may work with remote servers via terminal.
This allows you to:
- Have multiple terminals on the same connection
- Be able to disconnect from the terminal without terminating the running
- Share terminal with other users
How to install
To install tmux you can run this command:
apt-get install tmux
How to use:
You can create a new tmux session this command:
tmux
You can attach to an existing running session :
tmux attach
or a shorter version:
tmux a
Once you are on a tmux session you have the following shortcuts:
- Control+b+c: Open a new window.
- Control+b+d: Detach of a tmux session.
- Control+n: Move to the next window.
- Control+p: Move to the previous window.
- Control+b+number: Move to the number window.
- Control+b+”: Slit the window horizontally.
- Control+b+%: Split the window vertically.
- Control+b+$: Rename session
- Control+b+s: Change the session
Share a tmux session
You can share a tmux session with another ssh session with the same user via ssh.
Also if you can’t share the ssh connection you can use tmate.
You can install tmate with this command:
apt-get install tmate
Once tmate is installed you can run the command:
tmate
This will give you a list of ways to share the tmux session