One of the perks of having a Linux-based operating system installed is that you can take advantage of using Tmux. It is an excellent alternative for those who do not like or are tired of using GNU Screen.
Tmux has the same purpose, which means you can initiate a session and work with as many windows as you want inside it. Since each window is placed on the full screen by default, Tmux also comes with the opportunity of splitting the screen into panes.
The crucial benefit of Tmux is that you can use a single terminal to run multiple programs and seamlessly switch to the one you need. You do not have to be afraid of losing your connection because the sessions are persistent.
The important thing to note is that you should initiate each Tmux command with a suitable prefix. In most cases, it will be “ctrl+b.”
How to Install Tmux on Linux Distros
Please note that you will need to use an account that has super-user permissions. Make sure to include the “sudo” prefix if necessary.
Here are two different installation commands that you may use:
Debian and Ubuntu:
apt install tmux
Fedora and CentOS:
yum install tmux
Besides the mentioned operating systems, Tmux works on almost all Linux distros.
How to Start Using Tmux
The first thing you want is to initiate a session. You can do so by simply typing the following:
You will notice that a window is opened within the initiated session and a shell has started in that window.
Take a look at the lower part of the screen and notice that Tmux displays basic information about the session at all times.
At this point, you can start typing commands. If you want to know more about the available commands, here is what you should type:
How to Create and Name a Tmux Session
If you do not want to name your session, Tmux will use numbers to name them. However, it is a far better option to use descriptive words because it will help you to know the contents of each window exactly.
Here is how you can name a session when creating it:
tmux new -s my_session1
Simply change the “my_session1” with your desired name.
How to Detach and Reattach to a Tmux Session
For starters, let’s see how you can detach from a session. Use the following line:
Please note that detaching doesn’t mean that the program will terminate. Tmux will keep running the program even after detaching.
If you want to reattach to a session, here is how to do so:
tmux attach-session -t session_name1
Keep in mind that you will need to type the actual name of the session instead of “session_name1.”
If you are not sure what is the name of the session you want to connect to, you can command Linux to display all sessions with the following line:
The output will show you basic information about various sessions, including when it was created and other relevant data. The important thing to notice is that the session’s name is at the very beginning of the line.
How to Work with Tmux Windows
In the beginning, you will have one window in a session and a shell that started within it.
If you need an additional window, use the following line:
Tmux will assign a number to the window. You can take a look at the lower part of the screen to see all currently available windows.
In the following table, take a look at some options you may use together with the “ctrl+b” command:
- , – use it when you need to rename the window you are currently in at the moment.
- 0-9 – choose the corresponding number to change to that window.
- W – pick a window from the list of available ones.
- C – create a window and shell.
- “ – vertically split the pane you are in into two panes.
- % – horizontally split the pane you are in into two panes.
- X – close the pane you are in at the moment.
- ; – switch between the previous and the current pane.
We have now covered all the basic of using Tmux on a Linux-based operating system. Feel free to experiment with the commands and options listed in this guide to learn how to use this convenient alternative to GNU screen. If you consider you are skilled enough, you can check out the “.tmux.conf” file and customize Tmux to your preference, but we feel that the utility is very useful even the way it is by default.
Best Linux Distros for Developers and Programmers as of 2021
Linux might not be the preferred operating system of most regular users, but it’s definitely the go-to choice for the majority of developers and programmers. While other operating systems can also get the job done pretty well, Linux is a more specialized OS that was…
How to Install Pip on Ubuntu Linux
If you are a fan of using Python programming language, you can make your life easier by using Python Pip. It is a package management utility that allows you to install and manage Python software packages easily. Ubuntu doesn’t come with pre-installed Pip, but here…