Tmux: Getting started with the terminal multiplexer (Part One)

We continue with the freaks:

If you are used in a certain way to make extensive use of consoles (I include myself) you will have come across that the best option when undertaking certain tasks without throwing a lot of consoles on the desktop is to use a multiplexer that is nothing more than an entity that allows creating a stack of consoles accessible from the same terminal. In the best of cases we have tools such as Gnuscreen  which is obviously the best known and longest-lived option. The truth is that in the world of free software if we can find something, they are options to use. We literally have an almost endless range:

This time I want to tell you a little about Tmux

If like me you have Arch just make a pacman -S tmux to install it Users of other distros have them in the same way in the official repos.

Once installed we start typing tmux in a tertmial:

startmux

At first glance it is just a terminal waiting for commands to be executed and it certainly is. The first thing to run for this tutorial will be several terminals in a single window, for which we press the key combination:

Control + b Control +%

remaining as follows:

divide

As we will see, the workspace is divided into two first, but we can repeat the process as many times as necessary to achieve as many terminals as we want. Logically, perhaps with so many workspaces, we certainly need to order the arrangement of these terminals in a certain way. For which we press:

NOTE: in the first attempt of this combination of keys, the terminals will be adjusted to have an equal size in dimensions, so you will not see a change of position itself but an arrangement of them.

Control + b Space key

change of position

Now we are presented with the case of wanting to go from one terminal to the other, for which we use the logic of the direction of the keys up and down the keyboard. In this case, since we have two terminals one on top of the other, we press:

Control + b Down key (assuming pointer is in terminal above)

Control + b Up key (assuming the pointer is in the bottom terminal)

 In the case that we had more terminals, for example one in the from the upper terminal and once being located in the first terminal below we would use the direction logic of the keyboard keys that is:

Control + b Right key

deccionright

Now, as I mentioned in the input description, Tmux literally creates a stack of sessions in the same terminal. The command for this is:

Control + b c

new screen

From this moment on we will have created a new session (part of the stack that I was commenting on) and that we will be able to check by looking at the indicated part of the image (😛). We will see an asterisk changed to the terminal where we find exactly this as a guide. If we want to go back to where we started we press:
 
Control + b p (To return to the previous terminal) 
Control + bn (To go to the next terminal)
 
We will see the asteriz change places again. Each window is independent so you can divide and modify at will.
If we want to close one of the session windows we would have to press:
 
                                                                                                                                                                 Control + b &
 
injunction
 
In the part indicated in yellow we will see a closing confirmation dialog where we must place Y (to close) or N (to cancel the order)  Y / N . staying in the adjacent terminal after having answered the question affirmatively.
 
The question would be how useful do I give this tool? The answers are many, but the one that comes to my mind the fastest is: having several consoles for managing ssh accounts, network analysis, executing commands in a general way and system monitors without leaving a terminal increases the productivity of a person who has to deal with many terminals. 
 
In the second part of this introductory tutorial I will explain a little more about the internal configuration of Tmux and other features, although the manual provided by the developers is always available.  "Man tmux" 

I leave you an additional capture:

almost iii

Cheers-….


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

35 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   satanAG said

    Hello, excellent post. Clarifying and informing that it is in the Debian Wheezy repositories (7). Enough then, with an apt-get install tmux

    Greetings.

    1.    freebsddick said

      It is good that it has been of benefit to you. Cheers!!

    2.    eliotime3000 said

      I already installed it, and it works great for me.

  2.   Ezekiel said

    Above all, tmux is very useful when you connect remotely via ssh. Excellent entry!

    1.    freebsddick said

      Without a doubt .. Frankly it is the first use that comes to mind !! but of course the possibilities are very wide !! .. Greetings

  3.   Jesus Ballesteros said

    Thank you very much for this post, I was looking for something like this for KDE, previously I used the terminator emulator but there is no qt alternative that does the same, this helped me a lot.

    Best regards.

    1.    freebsddick said

      Well, sep .. it is a fairly ultimate tool .. which draws my attention because of its simplicity of use. maybe if you take a look at the official document you could achieve many interesting things. Cheers

    2.    pandev92 said

      I don't understand, doesn't konsole work for you? oO

  4.   question said

    Cool. But I still have one question: what difference is there to using a terminal emulator (like gnome's, for example) that allows you to open several tabs in the same application? It seems easier to me to use the one I mention, and most of the desktop environment terminals that I know have that possibility ...

    1.    freebsddick said

      The facility is a somewhat subjective fact. When a user has to use tools like urxvt, they look for simplicity, they do not look for it to be pretty (although it can be with some other additional configuration).

      In the case of rxvt if you have the possibility of having tabs properly identified with the fonts you prefer with the colors you want. I think the fundamental point of this is basically the consumption of resources. gnome terminal and others come with desktop environments generally so they use a lot more ram that could be insignificant on a relatively new computer but on a computer of a certain age any savings without removing functionality is something to consider

  5.   pandev92 said

    MHH looks interesting

    1.    freebsddick said

      People who tend to have terminals scattered on their desk and who also have little space to make use of it love these types of tools .. !! Also, if you use an environment like i3, which is a waterfall type manager, you can get a lot out of it because it saves a lot of space on the desktop.

  6.   Saito said

    Very interesting the truth and I have used it a couple of times but looking at performance, weight (Program dependencies), and ease I always end up returning to «terminator» which is a terminal with multiplexer included and tabs too, and it does the same to me, I can even save profiles and everything, I can open links without the need for a plugin like urxvt, you should try it ……

    That does not mean that Urxvt is beautiful, but for comfort and ease Terminator.

    Note if anyone wants the Terminator configuration, do not hesitate to ask me 🙂

    1.    freebsddick said

      In tmux there are also those characteristics .. If it is because of the number of programs I can make sure that just downloading Tmux you don't need anything else! Currently I have several machines without a graphical environment including running several services in parallel. Resource consumption is really important to me since the computers on which I use tmux are more than 10 years old. Regarding the terminal emulator in particular, I usually use zsh as the default console + urxvt. The point is that Tmux can save the sessions of what you have been doing without any problem in order to resume them at any time you want. What about the tabs you should know that just by activating the tabs in uxrvt you will already have that function .. Of course you must take into account that it is not that I am going to explain everything at once it would be too long for an introductory post That is why I am going to divide this into parts.

      If you want to check what I tell you, you just have to go to the official document, I assure you that you will find all those characteristics that you usually use with the tools that I comment on. Cheers…

    2.    eliotime3000 said

      I already installed it. Now, I am following the tutorial. Thanks for the warning, because I no longer have to necessarily install the ratpoison.

  7.   Ghermain said

    Something else to try and learn; the contribution is appreciated, although for now with Konsole in KDE I am doing well.

  8.   eliotime3000 said

    Good tool, although it is also valid to use RatPoison from time to time to work.

    So far the most KISS and easiest to use tool yet.

  9.   @Jlcmux said

    Hi. You can edit the tmux so that the console has colors. and all this that we edit almost all in the .bashrc?

  10.   Saito said

    If what you tell me is true, only as I said for ease and comfort, Terminator is better, an example:

    How do you divide the terminal into 2 horizontal parts
    Control + b and then the Space key

    How do you switch to the attached terminals:
    Control + by then Direction arrow

    How do I divide the terminal into 2 horizontal parts:
    Control + Down Arrow

    As a switch between attached terminals:
    Alt + Direction Arrow

    That one more step that needs to be done with tmux is that the two times that I have tested it well, I end up returning to terminator for that convenience, in addition to the fact that the configuration is not as long as in the case of Urxvt + Tmux

    And as I said of course that that configuration is beautiful, if only I could configure it in the same way that terminator happened to me right away, which I could not do (maybe because of laziness to configure, or because maybe I did it wrong)

    Good explanation in the post !!!!

    PS: I like your desktop is fluxbox right ???

    1.    freebsddick said

      Well I imagine that it is already a matter of taste .. for example I am looking for simplicity and I really see extremely simple the use of these two elements, I would have to make a post to describe the reasons. Maybe I have a little less tendency to use the mouse. .
      If it is fluxbox configured with few elements ..

      regards

  11.   tmux said

    for ease and convenience you have tmux, the key mapping can be assigned to what you sing.

    You can also create a socket and share sessions, and if you want something that pre-configures the environment or establishes permissions for the socket, you have scripts like tmuxinator to manage projects, and wemux to share sessions. And in this aspect, terminator falls short, in addition to consuming more resources than tmux.

    1.    Saito said

      As I said, terminator is easier and more comfortable due to the way you configure the keyboard shortcuts, I have not been able to configure it to be divided directly with (Control + Arrow) but always that I have used it is (Control + z + Arrow) , that's the way I could configure at least as I see it, it seems like one more step, but as "freebsddick" said it is more a matter of taste, I'm not going to a comparison fight between tmux and terminator, that as it says "msx" terminator is a graphic terminal, of course it comes with a multiplexer included unlike tmux that you can use it under a tty

  12.   msx said

    For all those who compare tmux with the rest of the graphical terminals:

    TMUX IS NOT A TERMINAL, IT IS A MULTIPLEXER OF TTYs / VTYs TERMINALS

    The main difference is that although Terminator, Konsole and friends can subdivide their main screens into many others, they always do it ON THE GRAPHIC LAYER.

    tmux and GNU Screen, on the other hand, emulate a text terminal by themselves, allowing UNDOUBLE the main container as a foreground application and continue running in the background.

    tmux is especially useful when we access remotely via SSH and when we need 100% reliability when executing certain non-graphical tasks in graphical environments that are not 100% reliable.

    Suppose we are doing a backup, scp or script execution that is going to take hours to complete and we cannot risk interruption: tmux comes to the rescue.
    Instead of executing said script, backup, or scp directly from a graphical terminal or having to log into a tty in text mode, we can invoke tmux, run the assigned task and undock the multiplexed terminal in case we don't need to see the feedback from our command.
    If for any reason our X session crashes quietly, we start a new session or go to a tty, we dock the current tmux session and continue from where we are.

    Or if, for example, we need to run a task that will require some time and we must move away from the machine, we can always access the running session of tmux via SSH and continue working from there.

    tmux is fantastic although with the latest modifications they made to Konsole I find myself using it less and less and only for some very specific tasks like the ones I mention above.

    http://i.imgur.com/L4JJI8m.png
    http://i.imgur.com/rfWjAMs.png
    http://i.imgur.com/oy5uqSN.jpg
    http://i.imgur.com/AN8guja.png
    http://i.imgur.com/og6NQBE.png
    http://i.imgur.com/JTH4SHc.jpg
    http://i.imgur.com/LaO9IUp.png
    http://i.imgur.com/fQoaKSk.png

  13.   just-another-dl-user said

    Excellent data, just the other day I needed something like this.

    1.    freebsddick said

      It's good that it serves you .. as long as I have some time I'll publish the second part 🙂

  14.   David Solorzano said

    One of the terminals that I recommend since it has that characteristic of being a multiplexer is the terminator, I recommend it
    To install it simple with aptitude install terminator

  15.   Dragnell said

    A pity, in elementary it does not work, Greetings

    1.    msx said

      QUE!?
      In the only elementary OS I have installed (Beta 2 a day) it is one of the first tools I installed.

      tmux works even on toasters, and if not check out the NetBSD project.

  16.   Algabe said

    Very good the Tmux very similar to Terminator, even though I'm used to using screen 🙂

  17.   snock said

    Can you mix konsole with tmux?

    1.    msx said

      They do not mix, they complement each other, check the screenshots of my comment above.

  18.   build said

    Tmux is amazing on its own and also in combination with Vim. For those who use screen, the step to Tmux is direct, it is only a matter of mapping ctrl to ctrl and learning a few commands.

  19.   Dvirus said

    tmux = Terminator

    Provides a fully-functional command line interface (CLI) for Linux, Arrange terminals in a grid, Open multiple sessions in tabs, Drag and drop re-ordering of terminals, Lots of configurable keyboard shortcuts, Save multiple layouts and profiles in the preferences, Simultaneous typing to arbitrary groups of terminals, Customizable visual style.

  20.   Luigi said

    Excellent, it has served me a lot.

  21.   trading cards said

    thank you very much for the contribution