Tmux is a terminal multiplexer an alternative to GNU Screen. In other words, it means that you can start a Tmux session and then open multiple windows inside that session. Each window occupies the entire screen and can be split into rectangular panes.
With Tmux you can easily switch between multiple programs in one terminal, detach them and reattach them to a different terminal.
Tmux sessions are persistent, which means that programs running in Tmux will continue to run even if you get disconnected.
All commands in Tmux start with a prefix, which by default is ctrl+b.
how to use tmux
# syntax
tmux <options> <session>
##### create a new session
tmux new -s session_name
##### show all running tmux sessions
tmux ls
##### attach to a session
root@Corrosie:~# tmux ls
testSession: 1 windows (created Sun Aug 9 09:11:00 2020)
root@Corrosie:~# tmux attach-session -t testSession
##### tmux options (in the tmux session)
Ctrl+b c # Create a new window (with shell)
Ctrl+b 0 # Switch to window 0 (by number ) [IMPORTANT]
Ctrl+b n # go to the next screen (right side)
ctrl+b p # go to the previous screen (left side)
Ctrl+b , # Rename the current window
Ctrl+b % # Split current pane horizontally into two panes [IMPORTANT]
Ctrl+b " # Split current pane vertically into two panes [IMPORTANT]
Ctrl+b o # Go to the next pane (alternative = ctrl+b <terminalscreen number>
Ctrl+b x # Close the current pane
Ctrk+b z # increase the window size of you current terminal to the full size, use this combination again to shrink it to origin size
ctrl+b [ # scroll through your terminal output, use 'q' to quit this feature.
##### switching through tmux panes
ctrl+b <ARROW KEYS>
##### detaching from sessions
ctrl+b d # detach from current terminal session
ctrl+b D # detach from the entire terminal session
##### kill all tmux sessions
# in any terminal:
tmux kill-server
tmux script - specific
Here is an example of a tmux script, this script will connect you to your own tmux session. with predefined tmux windows, and tools.
note: this scripts requires that tools are installed, like openVAS, Metasploit, openvpn etc. Also, it is redirecting to local directories that are not present on a default Linux installation. If you would like to try and test this, check out the next subject "tmux script - general example"