Is it possible to have several terminals in a single one? Well, the answer is yes, and it is thanks to a utility that today I will tell you a little about. In this post, you will learn how to install Tmux on Linux.
What is Tmux?
According to the GitHub profile of the tool.
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.
The main uses of tmux are to:
- Protect running programs on a remote server from connection drops by running them inside tmux.
- Allow programs running on a remote server to be accessed from multiple different local computers.
- Work with multiple programs and shells together in one terminal, a bit like a window manager.
Therefore, Tmux is an essential tool for users who need to manage many terminals without problems. Even for a novice user, it is very useful to know it.
Although it is easy to use it, some people may find it difficult to grasp the concepts of session and so on.
Installing Tmux on Linux
Fortunately, Tmux is present in the official repositories of most Linux distributions out there. This is a great advantage in time factors.
If you use Debian, Ubuntu, Linux Mint or any other member of this family, you can install it using this command
sudo apt update sudo apt install tmux
Thereafter, you will be able to use it.
For CentOS, Fedora, RHEL, and derivatives such as Rocky Linux or Alma Linux, just run the following command:
sudo dnf install tmux
As you can see, it is available for many Linux distributions without too many issues.
Basic use of Tmux
The operation of
tmux can be understood through two concepts, such as sessions and commands.
Each time you start tmux, a new terminal session is created where a window with shell access is displayed.
To create a new session, you have to choose whether to give it an identifying name.
If you want to create it, run
But if you would like to create it and assign it a name, then run
tmux new -s [name]
In either case, you will see a common window, but at the bottom you will notice a status bar.
The other concept is command line. And that is that the administration of
tmux is command-based. To enter one, you have to execute first the default prefix, which is
CTRL + b.
For example, to list all available commands the command is
? so to execute it, you will have to press
CTRL + b and then
esc key to exit.
Another incredible utility of tmux is the ability to exit and re-enter a session. First, exit the session with the command
d Remember that it must be preceded by the prefix
CTRL + b and then
You will return to your normal terminal, and you will have this message
[detached (from session imaginelinux)]
Now if you want to return to this session, run
tmux attach -t [session]
Now if you don’t remember the session name or if you didn’t assign one, you can check the list of sessions with this command
You will get an output screen like this
imaginelinux: 1 windows (created Tue Jul 5 10:39:54 2022)
Of course, if you had made more sessions, they would all appear there.
Now just go back to it
tmux attach -t imaginelinux
And you will have the session back as you left it. This means that if you were running a command, it will continue to do so.
More uses of Tmux
tmux session, you can create another one with the
c command. It will then be assigned the first number between 0 and 9 that is available. For example, if you created a single session that corresponds to the number 0, after executing the
c command then the
1 session will be created.
To help you avoid confusion, you should always look at the status bar at the bottom of the window because it tells you which session you are in.
Another important utility of
tmux is that we can split the window into several terminal sessions. If you want it to be vertical, then the command is
Other important commands used in
cCreate a new window.
wChoose window from a list
0Switch to window 0 (by number)
,Change the name of the current window
%Split current pane horizontally into two panes
"Split the current panel vertically into two panels
oGo to the next pane
;Switch from the current pane to the previous pane
xClose current pane
So, you can use
tmux in a basic way.
tmux tool is designed to get the most out of the terminal. This is appreciated by Linux professionals, but also by novices who want to use the terminal more.
I hope you liked this post and help us to share it with all your friends.