Linux Tutorials - Herong's Tutorial Examples - v5.45, by Herong Yang
"tmux" - Terminal Multiplexer
This section provides a tutorial example on how to use 'tmux' tool to manage multiple shells as windows and panes in a single terminal. 'tmux' automatically keeps all shells running when the terminal is disconnected.
What Is "tmux"? - "tmux" is a terminal multiplexer. It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal.
Here is the official description of "tmux" from its manual page:
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. When tmux is started it creates a new session with a single window and displays it on screen. A status line at the bottom of the screen shows information on the current session and is used to enter interactive commands. A session is a single collection of pseudo terminals under the management of tmux. Each session has one or more windows linked to it. A window occupies the entire screen and may be split into rectangular panes, each of which is a separate pseudo terminal (the pty(4) manual page documents the technical details of pseudo terminals). Any number of tmux instances may connect to the same session, and any number of windows may be present in the same session. Once all sessions are killed, tmux exits. Each session is persistent and will survive accidental disconnection (such as ssh(1) connection timeout) or intentional detaching (with the 'C-b d' key strokes). tmux may be reattached using: $ tmux attach In tmux, a session is displayed on screen by a client and all sessions are managed by a single server. The server and each client are separate processes which communicate through a socket in /tmp.
"tmux" is a nice tool that reduces the number of remote "ssh" sessions, saves time on trying to push processes to the background manually to prevent be killed by connection timeouts. Here is what I tried on my CentOS computer.
1. Install "tmux":
herong$ sudo dnf install tmux Installed: tmux-2.7-1.el8.x86_64
2. Use "tmux" command to start a new "tmux" session, which starts a shell as the first pane in the first window of the "tmux" session.
herong$ tmux (in a child shell in "tmux") herong$ exit (back to the original shell)
3. Use the following hot keys to control its windows and tabs:
ctrl-b, % split the screen in half from left to right ctrl-b, " split the screen in half from top to bottom ctrl-b, array_key switch to the pane in different directions ctrl-b, c create a new window ctrl-b, 0|1|... switch to a given window ctrl-b, d detach from tmux, leaving it running in the background ... ctrl-b, ? display all hot keys
4. Use "tmux ls|attach" to list and reattach to a detached or disconnected tmux session.
herong$ tmux ls 0: 1 windows (created Tue Aug 25 20:16:44 2020) [122x42] herong$ tmux attach (old tmux is displayed again)
Table of Contents
Cockpit - Web Portal for Administrator
"ps" - Display Current Processes
"jobs" - Manage Background Jobs
►"tmux" - Terminal Multiplexer
SELinux - Security-Enhanced Linux
SSH Protocol and ssh/scp Commands
Software Package Manager on CentOS - DNF and YUM
vsftpd - Very Secure FTP Daemon