Here only tested and working commands. Used in
Ubuntu 24.04 LTS
tmux is very good for opening one terminal session inside another,
tmux new - sessionname
To navigate through terminals use,
- Ctrl-b + d – detach from the current session.
- Ctrl-b + % – splits a window into upper and lower panes.
- Ctrl-b + ” – splits a window into two vertical panes.
- Ctrl-b + arrow – moves to a different pane in a direction.
- Ctrl-b + x – closes the current pane.
- Ctrl-b + c – creates a new window.
- Ctrl-b + n – switches to the next window based on its number.
- Ctrl-b + p – returns to the previous window.
- Ctrl-b + ID number – jumps to a specific window using its ID number.
- Ctrl-b + : – opens the command line mode.
- Ctrl-b + ? – prints all shortcuts.
- Ctrl-b + w – lists all windows in the current session.
learn more about tmux at Tmux Tutorial: What It Is, How to Install It, and Command List (hostinger.com.br)
⚠️ Researches elaborated with the aid of Deep Research are subject to referential ambiguity.
🖥️Clean HTML code using a proprietary tool.
👥Research by Guilherme Felipe, Curation by Sílvio Lôbo
The Hidden Power of the Terminal: Unveiling tmux
In the Linux universe, where the command line reigns supreme, efficiency and organization are golden coins. Among the tools that elevate productivity to surprising levels, tmux (Terminal Multiplexer) stands out. Far from being just another command, tmux is a work environment within your terminal, allowing you to manage multiple sessions, windows, and panes simultaneously and persistently. This exploration will be dedicated to demystifying its use, highlighting its crucial points, and unraveling aspects that may cause some initial strangeness.
What is a Command in Linux and How to Use It?
In the Linux context, a command is an instruction you type into the terminal for the operating system to perform a specific task. Common examples include ls to list files, cd to change directories, and clear to clear the screen.
tmux, on the other hand, is not a command that executes a single, punctual action, but rather a program that creates and manages a work environment. To use tmux, you typically run it by typing its name in the terminal:
tmux
By doing this, you enter a new tmux session. The first impression might be of a terminal that looks identical to the one you were using, but the presence of a bar at the bottom (the tmux status bar) already indicates that something has changed. This bar displays information about active sessions, windows, and panes.
Key Points and tmux Architecture
tmux operates under a client-server model. A tmux server runs in the background, managing sessions. tmux clients are the terminal instances that connect to this server. This architecture is fundamental to tmux's most impressive feature: session persistence.
Session Persistence: The Magic That Accompanies You
This is undoubtedly tmux's main differentiator. You can start a session, run commands, open multiple panes and windows, and then detach from the tmux server without losing your work. Imagine you are on a remote server via SSH, and your connection drops unexpectedly. Without tmux, all your progress is lost. With tmux, upon reconnecting, you can simply "reattach" to the existing session and resume where you left off.
The commands for managing sessions include:
tmux new-session -s session_name: Creates a new session with a specific name.tmux attach-session -t session_name: Reconnects to an existing session. If you don't specify the name, it reconnects to the last active session.tmux detach: Detaches from the currenttmuxserver, keeping the session active.tmux list-sessions: Lists all active sessions.
Windows and Panes: Infinite Organization
Within a tmux session, you can create multiple windows. Think of windows as tabs in a browser. Each window can have its own pane configuration. Navigation between windows is done through keyboard shortcuts.
Within each window, you can split the space into multiple panes. This is the true power of multiplexing: having several terminals side-by-side or one above the other, allowing you to monitor processes, edit files, and run commands simultaneously.
The most common shortcuts (the default prefix is Ctrl+b) include:
Ctrl+b c: Creates a new window.Ctrl+b n: Navigates to the next window.Ctrl+b p: Navigates to the previous window.Ctrl+b %: Splits the window vertically (creates a new pane to the right).Ctrl+b ": Splits the window horizontally (creates a new pane below).Ctrl+b arrows: Navigates between panes.Ctrl+b x: Closes the current pane or window (with confirmation).
The Prefix: The Key to Control
Almost all tmux functionalities are accessed through a "prefix" followed by another key. The default prefix is Ctrl+b. This means, to create a new window, you press and release Ctrl+b and then press c.
This prefix is configurable, and many users remap it to something more convenient, such as Ctrl+a, which was the prefix for the older screen, another terminal multiplexer.
Curious Points and Initial Strangeness
The learning curve for tmux, like that of many powerful tools, can present some points that cause strangeness.
The Prefix Behavior
In the beginning, the need to press a prefix before each command might seem redundant and disrupt the natural typing flow. The mind is accustomed to pressing a key and seeing the action happen immediately. tmux requires a pause and a second touch. Overcoming this strangeness comes with practice, when the prefix becomes an almost automatic gesture and the gain in control and organization compensates for this initial "interruption."
What Happens When the Window "Dies"?
If you close a terminal that is connected to a tmux session, the tmux server and its sessions continue running. This is persistence in action. However, if you close an individual pane within tmux (using Ctrl+b x), tmux might exhibit behavior that seems a bit counter-intuitive to newcomers. Instead of simply disappearing, tmux might display a message like "disconnected (press Enter or Ctrl+c to exit)." This happens because tmux is preserving the state of the process that was running in that pane. Pressing Enter reconnects to the process if it's still running, or pressing Ctrl+c effectively terminates the pane.
Multiple Re-attachment
A scenario that can cause confusion is when you try to reattach to a session that is already being used by another terminal instance. tmux, by default, does not allow multiple terminal clients to have full control over the same session simultaneously. If you try to reattach while a session is active on another machine (or even in another window of the same terminal), you will see a message indicating that the session is already in use. The default behavior is that the old session is disconnected. However, there are configurations to allow shared viewing, but simultaneous write control is complex and generally not recommended.
Configuration: The Hidden Power of Customization
Although tmux is highly functional "out of the box," its true potential is revealed through configuration. A file named .tmux.conf, located in the user's home directory, allows you to customize almost every aspect of tmux: the prefix, keyboard shortcuts, the status bar's appearance, pane splitting behavior, and much more. Ignoring configuration is like driving a sports car without ever opening the hood; it drives, but it doesn't show its full performance.
Conclusion
tmux is more than just a command; it's a terminal productivity ecosystem. Its ability to manage persistent sessions, split the workspace into windows and panes, and its vast configuration capabilities make it an indispensable tool for developers, system administrators, and anyone who spends a considerable amount of time in the terminal. The initial strangeness is temporary, overshadowed by the convenience and power it unlocks. Mastering tmux is, in essence, mastering your own work environment in Linux.



