April 20, 2016
by Rares Aioanei
Introduction
If you’re new to server administration and command-line, perhaps you haven’t heard of terminal multiplexers or what they do. You want to learn how to be a good Linux sysadmin and how to use the tools of the trade. Or perhaps you’re a seasoned administrator already and administer quite a few machines, and want to make your life a little easier. Or maybe you’re somewhere in between.
Either way, this article will explain what terminal multiplexers are, what they do and most importantly, how you can benefit from using them.
A terminal multiplexer is nothing more than a program that allows its user to multiplex one or more virtual sessions, so the user can have several sessions inside one single terminal. One of the most useful features of such programs is the fact that users can attach and detach such sessions; how is this useful will become clear shortly.
Use cases
Persistent sessions
Let’s say you have to administer a remote server via ssh/command-line but your connection is not very stable. That means you have to reconnect often and don’t want to start work all over again. Terminal multiplexers offer the feature of saving your sessions between connections so you can continue just where you started.
Please note that such sessions are not persistent between reboots (in our case above, reboots of the server you’re connecting to) so it’s best to know this in order not to expect such a feature. The reason for this is the fact that the multiplexer runs shell sessions, from which you may be running a text editor, a monitoring tool and whatnot. Since all those processes will not be there anymore after a reboot, there is no reason why this feature should be implemented as it would not have any real use.
We spoke in our introduction about attaching and detaching : this is exactly what this feature does. Continuing with our use case, where you have an unstable connection, once you get disconnected, you can just ssh into the server again and reattach to the running session (or choose between sessions to reattach to) and you’ll be right where you
left off.
Read more