
If you regularly work in the line of commands de Linux or macOS, you've probably already heard of TMUX, a tool that makes it much easier to manage multiple terminals and tasks at the same timeFor those managing remote systems such as servers or simply looking to streamline their workflow on the go, terminal, TMUX is a must-have solution.
TMUX is a terminal multiplexerWhat does this mean? In a nutshell, it allows you to open multiple terminal sessions within a single window, dividing the space into separate panels and windows. Even after you close or log out, the sessions will continue in the background, making it a perfect tool for working in the background or on remote systems.
What is TMUX?
TMUX, short for 'Terminal MUltipleXer', is a software that allows users to manage multiple terminal sessions in a single workspace.
It works in a similar way to other tools like GNU Screen, but offers very powerful features for manipulating sessions and panels dynamically. This means that you can divide your console into several sections, switch between them without complications, and, above all, keep tasks or processes running even if you close the terminal or lose connection to a remote server.
For example, if you are managing a remote server through SSH and your connection is interrupted, the session of TMUX will continue running in the background. You can reconnect later and pick up where you left off without losing any progress.
How to install TMUX?
Before you can start enjoying the benefits of TMUX, you first need to install it. TMUX is available in the official repositories of most Linux distributions and on systems like macOS.
- On Linux (Debian, Ubuntu): You can proceed to install TMUX from the package manager by running the following command in your terminal:
sudo apt install tmux. - On macOS: If you prefer this tool on macOS, you can use Homebrew, a popular package manager. The command to do so is:
brew install tmux.
Once installed, make sure it has installed correctly by checking the version with the command: tmux -V.
How to get started with TMUX
To start using TMUX It's very simple. Open your terminal and enter the command:
tmux
This will automatically create a new TMUX session and launch a terminal window within that session. At the bottom of the window you will see a status bar displaying information about active sessions.
If you would like to give a name to your session, you can do so by adding the option -s to the command, as follows:
tmux new -s nombre_de_sesion
This is useful when you are managing multiple sessions simultaneously, as it allows you to easily identify them.
Managing TMUX sessions
One of the main characteristics of TMUX is the ability to easily manage multiple sessions. Here are the key commands:
- Create a new session: To create a new session separate from the one you already have running, use the command:
tmux new-session -s nombre_de_sesion. - List all sessions: If you want to see what sessions you have open, run:
tmux ls. - Join an active session: If you have created a background session and want to return to it, use:
tmux attach-session -t nombre_de_sesion. - Unlink a session: To continue with other tasks without closing a session, press Ctrl-b + d. Your session will continue running in the background.
- Delete sessions: Finally, if you want to delete a particular session, do so with:
tmux kill-session -t nombre_de_sesion.
Division into windows and panels
TMUX allows you to split a session into multiple windows and divide those windows into panes. This feature is especially useful when you want to perform different tasks in parallel without having to constantly open new terminal tabs.
Split windows
Each TMUX session starts with a single terminal window. To create more windows within the same session use the key combination:
- Ctrl-b + c: This will open a new terminal window within the current session.
- Ctrl-b+n: It will navigate to the next window.
- Ctrl-b + p: Will navigate to the previous window.
- Ctrl-b + number: Allows you to jump directly to a window by its number.
Split panels
Aside from windows, you can also split each window into multiple “panes.” This gives you a way to manage your work even better, as you can run different tasks in each pane without switching windows.
To divide the window into panels use these keyboard shortcuts:
- Ctrl-b + %: Splits the window vertically (into two columns).
- Ctrl-b + “: Splits the window horizontally (into two rows).
To move from one panel to another, you can use Ctrl-b and then the arrow keys.
If you want to adjust the size of the panels, you can do so using Ctrl-b combined with Alt and the arrow keys.
TMUX customization
One of the cool features of TMUX is that it is highly customizable. You can create a configuration file that allows you to fine-tune the TMUX experience to your needs.
To create a local configuration file that applies only to your user, open a file .tmux.conf in your home directory:
sudo touch ~/.tmux.conf
Within this file, you can configure things like your preferred key bindings, the appearance of panels, and even enable mouse use to manage panels.
For example, to change the default shortcut of Ctrl-b a Ctrl, add the following to your configuration file:
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
Additionally, to enable mouse usage you can include:
set -g mouse on
Advanced Commands and Modes
TMUX features a wide range of advanced commands that allow you to do things like move your panels, resize them, or even replicate entire sessions.
For example, you can move a panel to a new window using the command:
Ctrl-b + !
You can also swap the position of two panels using:
Ctrl-b + { o }
Another useful command is command line mode, which allows you to run any TMUX command interactively. To activate it, use:
Ctrl-b + :
Advantages of using TMUX
Unlike the traditional Linux terminal, which only allows you to work in one session at a time, TMUX offers a multitude of key advantages for system administrators or developers:
- Multitask: With TMUX you can work in multiple sessions simultaneously and manage long tasks without the risk of losing them in case of disconnections.
- Persistence: TMUX sessions continue to run even after you close the terminal or disconnect from the server.
- Efficiency: With panels and windows you can divide your work in a more organized and efficient way within the same terminal window.
- Flexibility: The ability to customize TMUX with configuration files makes it suitable for any type of user or workflow.
If you often work with remote systems or need to run multiple processes on the terminal, TMUX is a tool that gives you full control over your work environment. From creating persistent sessions to dividing terminals into panels, it allows you to maximize your productivity without any additional effort.
I'm Alberto Navarro and I'm passionate about everything related to technology, from cutting-edge gadgets to software and video games of all kinds. My interest in digital began with video games and continued in the world of digital marketing. I have been writing about the digital world on different platforms since 2019, sharing the latest news in the sector. I also try to write in an original way so that you can stay up to date while having fun.
I studied Sociology at university and completed my studies with a Master's in Digital Marketing. So if you have any questions, I'll share with you all my experience in the world of digital marketing, technology and video games.
