I have been using a terminal multiplexer since the late 1980s and I could not function without one.
What even is a terminal multiplexer? This type of software fills the role for text terminals that a remote desktop solution like Anydesk providers for graphical environments. This means you can log into a remote system, start your terminal multiplexer, get one or more programs running, perhaps while logging their output, and then you can simply close your local terminal. All the stuff you were doing remains running under the multiplexer at the far end. You can come back later, reattach, and see how things are working.
There are two uses this will have for people following IIB.
Those who switch to Linux for an investigation platform will want to get ProtonVPN working fairly quickly. There are a lot of guides that show how to make an OpenVPN connection part of the system’s normal startup sequence. This has always been shaky enough that I just run an OpenVPN session under tmux. Since some of you are aware of the WireGuard alternative to OpenVPN. The config portion of that is smooth, but the performance I got as a paying customer was just miserable, so I’ve avoided it.
But Which One?
When I started I was using the only terminal multiplexer available - the venerable GNU screen. I frequently hated on it, because its command key was the same as the Minicom serial terminal program I used, so there were endless situations where I’d have to log in a second time and issue a kill command screen, then restart Minicom with a different command key.
You probably perceive me as a change agent, but that’s only when I’m inflicting it on others. My temperament was to stick with things that work and now that I have an AARP card I’m really not into gratuitous new adventures. But I got a suggestion to try tmux, did so, and after a month I rewired my brain to the point I can hardly use screen any more. Here’s an example of tmux in action, lifted from its Wikipedia entry.
You can do split screens and stuff, but I usually use the carousel. You can run as many different shells as you want. A typical use case would be having tshark, the terminal version of Wireshark, running in one window, and some new daemon I’m trying running in another without letting it go into the background.
A very common mistake for new VPS operators is over-configuring a machine so they can have a familiar graphical environment in which to keep things running. If you master a few of the tmux basics you’ll be free of that. Keep in mind when reading these examples that ctrl-b is the command key - switches input from the program you see on the terminal to controlling tmux itself.
Here are some of the most common commands I use with it.
tmux - starts it.
tmux ls - show running tmux sessions.
tmux attach - pick a session from tmux ls to rejoin.
My most command command key options are:
ctrl-bd - d for drop, puts it in the background.
ctrl-bw - w for windows, gives you a list of tmux sessions.
ctrl-bP - P I guess for print, toggle logging to a file on and off.
If you want logging, you’ll need to install the logging plugin in your home directory using git CVS to copy the files.
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
And then add these four lines to your ~/.tmux.conf
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
run '~/.tmux/plugins/tpm/tpm'
set -g @plugin 'tmux-plugins/tmux-logging'
Conclusion:
This is one of those little things that’s very familiar to we old dogs, but those who are new to Linux may never have seen it in action. While it’s just a simple little thing, tmux offers a big productivity boost with just a tiny time investment to get there.