2005-11-05 Linux:

Techie stuff today, and lots of it.

There are three kinds of people in the world. Those that use screen, a little Unix/Linux command line app and rave about it, those who’ve heard about it, could use it but don’t. And the other 99.99% of the world’s population who neither know nor care.

I’m in the first group, of course. It’s easy to see why even those that know what if it don’t use it, because it’s such a simple little utility that it’s easy to overlook. On my system it’s just 319k in size. Aside from vim, the text editor from Heaven, and OddMuse, the wiki from the Happy Hunting Groups, it’s the single most used and useful app I’ve got on this box.

What is does it twofold. The magic is in Part Two, but Part One is kinda funky too.

Firstly, it takes any terminal window or console (read: command line for you non-Linux chicks), and makes it multiply. This means that instead of having many terminal windows open and having to alt-tab through all the lot to find the one I want, I’ve just got a single terminal open. Screen lets me create new windows within that one term. For a start, that’s incredibly memory efficient. Even using aterm (my term of choice), memory can soon get eaten up. I can routinely have 10 different sessions open. If each one it an aterm, that’s a fair few meg of memory gone before I do anything else. Using KDE’s much less efficient konsole, memory usage starts to get noticeable with just 5 windows open.

Using screen I just need one terminal open. When I run screen, nothing seems to happen, but now, I can type CTRL-A c and create a new window. And another. And another. Pressing CTRL-A twice acts like ALT-Tab, cycling between the last two I’ve opened. Pressing CTRL-A then a number takes be to that numbered window. I can also press CTRL-A A and give the current screen a name, so I don’t get lost. CTRL-A w shows a little cribsheet of which screens I’ve created, and CTRL-A “ brings up a menu list to select one using the cursors.

All nice, simple and straightforward. This works everywhere by the way, not just in high-graphics X11. I can use screen on a text console, or even remotely through ssh.

That’s where Part Two comes in, and this is where screen really shines.

Let’s say you’ve got 20 screens open, logged into several systems remotely, an email client open, some code you’re working on in vim, that great novel which will make your fortune and all the rest of life’s little pleasures.

Then the screen freezes and you have to restart.

All that work, those connections, the last 1,000 or so words of your novel – gone.

Not so with screen. If the terminal window closes for any reason, screen stays persistent. It’s still running in the background, with all those windows just waiting for me to reconnect. I can do that from anywhere – the same computer, a text window or even 6,000 miles away via ssh. Typing screen -r restores that session, and I’m back in business. In effect, screen is acting as a failsafe, enabling me to keep my work up and running no matter what happens, or where I happen to be.

Now, we’ve all lost work at some point because of substandard programs and the like. I’m sure that Murphy has a law somewhere that states that the more important the work, the longer it’s been since you’ve saved, the more likely it is that something Will Go Wrong. screen is a safety belt for the soul.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.