I'm a huge fan of the command line and always have been. If you're like me, you're most comfortable at the keys in a dark terminal session. Most of my day to day work can get accomplished through a terminal, with the rare case of needing a graphical web browser.
As both a network engineer and systems admin, I have a lot going on at any given time. There are two tools I believe we all use, stuff happening in the background, and an organized classification of our work areas, often times separated.
This is a good way to classify projects, environments, testing, coding, you name it. Each workspace has it's own separation. I'm often logged into dozens of servers, iot devices, lab machines, vms, cloud instances. It helps to stay organized.
And I'm not going to log into these resources everytime I swap client machines I'm working behind. I could be using a linux machine, a chromebook, a windows laptop, bastion host, or temporary container. I need stuff to continue to run in the background.
This is where GNU Screen comes in. I've used it for years. How to use screen is a bit out of the scope of this post, but the quick description is that it's a terminal muxer. It takes one ssh session and creates a back-end of many sessions. You can disconnect and leave them running, move to a different client, and re-connect later. This is great for long-running processes like compiling or creating stacks or container environments. Commands are based on a hot-key "ctrl-a". For example, to switch to the next screen session, "ctrl-a n".
Now somewhere on the internet, there's a holy war raging. There are people who prefer tmux, an alternative to GNU screen. Each has their own pros and cons, and for a while I switched from exclusively screen to exclusively tmux. But wait, these are open source tools, can't I use both? The hot-key for tmux is "ctrl-b" and some of the commands overlap. Ie, next-session in tmux is "ctrl-b n".
The diagram shows my new setup. Tmux handles my groups. Screen handles my sessions inside those groups.
Typically I use up to nine sessions in each screen session, so this allows me to have eighteen sessions muxed into one, grouped into two groups. I've found a more comfortable working number is somewhere between 12-15.
This is just the tip of the iceberg when it comes to tools. Don't even get me started on mosh, the mobile shell which uses protocol buffers (from Google) to resume roaming sessions.
[Update]: I've been using the same tmux-start script for a while, and roughly 23 sessions (20 screens + 1 more tmux group with 3 panes). I was comfortable, so automated it a bit.
I have also added it as a gist here, please ignore my joke about it exploding everything, but seriously you should completely understand things you find randomly on the internet, before running.
Top comments (0)