Terminal Multiplexer (Tmux)

Tmux

Tmux (Terminal Multiplexer) is a free and open-source program for managing multiple virtual terminals inside one physical terminal. With tmux, you can split your terminal into multiple windows and panes, switch between them, and run multiple terminal sessions in one window. Additionally, tmux allows you to save terminal sessions and restore them at any time, which can be very useful for working with long-running processes.

Tmux can be especially useful for developers and system administrators who often work with multiple terminals and processes simultaneously. It can also be useful for users who want to use the same terminal to run multiple tasks, including for remote server management."


Create New Session

  1. Start a new Tmux session with the name "Ping_Google_com":
tmux new-session -s Ping_Google_com
  1. Ping Google.com
svc-admin@ubuntu:~$ ping google.com
PING google.com (173.194.222.113) 56(84) bytes of data.
64 bytes from lo-in-f113.1e100.net (173.194.222.113): icmp_seq=1 ttl=53 time=36.6 ms
64 bytes from lo-in-f113.1e100.net (173.194.222.113): icmp_seq=2 ttl=53 time=36.4 ms
64 bytes from lo-in-f113.1e100.net (173.194.222.113): icmp_seq=3 ttl=53 time=36.5 ms
64 bytes from lo-in-f113.1e100.net (173.194.222.113): icmp_seq=4 ttl=53 time=36.6 ms
  1. To detach from the current Tmux session and leave the ping running, use the hotkey Ctrl+B and then press D.

  2. List the existing Tmux sessions to verify that the "Ping_Google_com" session is still running:

tmux list-sessions
  1. The output should be similar to this:
Ping_Google_com: 1 windows (created Wed Apr 12 10:03:11 2023)
  1. To reattach to the "Ping_Google_com" session and see the output of the ping command, use the following command:
tmux attach-session -t Ping_Google_com
  1. This will reattach you to the Tmux session and you can see the output of the ping command. You can detach from the session again using the hotkey Ctrl+B and then pressing D.

Delete Session

  1. To close a Tmux session, you first need to detach from it. You can do this by using the hotkey Ctrl-B and then pressing D.
  2. Once you have detached from the session, you can close it by using the tmux kill-session command followed by the name or ID of the session you want to close.
  3. Check list session:
tmux list-sessions
Ping_Google_com: 1 windows (created Wed Apr 12 10:03:11 2023)
start-web-server: 1 windows (created Wed Apr 12 10:01:46 2023)
  1. tmux kill-session -t Ping_Google_com

Key Pane Controls

Ctrl + B, "         split pane horizontally
Ctrl + B, %         split pane vertically
Ctrl + B, o         next pane
Ctrl + B, ;         prior pane
Ctrl + B, ←↑→↓      jump to pane
Ctrl + B, Ctrl + O  swap panes
Ctrl + B, Space     arrange panes
Ctrl + B + ←↑→↓     change pane size
Ctrl + B, !         pop a pane into a new window