Tmux is a console utility that allows you to manage multiple windows and panes within a single session. The state of the windows can be saved and restored even after a connection is interrupted. The key advantages of Tmux include:
Managing multiple processes in one window.
Easy switching between sessions and panes.
Connecting multiple users for collaborative work.
The ability to restore sessions at any time.
Besides Tmux, other multiplexers like GNU Screen or dvtm exist, but Tmux has become the most popular due to its ease of use and flexibility in configuration.
Tmux lets you split windows into panes, adjust their sizes, navigate between them, and use each as a separate terminal. This is especially useful for multitasking.
Even if your connection is interrupted, you can restore your work by returning to the last saved state. This feature is particularly valuable for remote work over SSH.
Tmux supports mouse input, simplifying window management. You can resize panes, switch between them, and even scroll through text using the mouse.
Multiple users can connect to a single Tmux session simultaneously, view each other’s actions, and work on tasks in real time. This makes it an excellent tool for team projects.
To install Tmux, you'll need two primary libraries:
libevent for event handling.
ncurses for working with text-based interfaces.
You can install Tmux through your system's package manager. After installation, it’s recommended to create a configuration file (~/.tmux.conf) for personal settings.
Tmux is indispensable for connecting to remote servers. If your connection drops, the session remains active, and you can reconnect from any device.
Command to restore a session:
tmux attach
Tmux supports automatic command execution at startup. You can configure scripts to launch specific applications or services in separate panes. For example, you can automatically open a text editor, server, and monitoring tool in different windows.
Using Tmux, you can run monitoring tools like htop, tail for logs, or network status utilities in separate windows. This allows you to monitor multiple processes simultaneously.
For teamwork, create a single session that all members can connect to. Commands are synchronized, and all participants can see real-time changes. This is particularly useful for debugging and server configuration.
Create a new session:
tmux new
Attach to an existing session:
tmux attach
List all sessions:
tmux ls
Kill a specific session:
tmux kill-session -t [name]
Split window vertically: Ctrl+b %
Split window horizontally: Ctrl+b "
Navigate between windows: Ctrl+b n (next), Ctrl+b p (previous)
Close a window: Ctrl+b x
Select a pane:
select-pane
Swap panes:
swap-pane
Resize panes:
resize-pane
Enable copy mode: Ctrl+b [
Scroll through text: PgUp, PgDown
Unicode Support
The following option ensures proper display of multilingual text, special characters, and emojis:
-enable-utf8proc
Static Build
This command creates an executable file independent of system libraries, making it portable:
-enable-static
Debugging Tools
This option adds debug symbols for easier troubleshooting and program analysis:
-enable-debug
Tmux is a versatile tool that simplifies terminal work. It is invaluable for session management, monitoring, task automation, and even team collaboration. By mastering its basic commands and configurations, you can maximize the utility of this powerful application.