Chovy's Blog

Web Development with Node.js, PHP, Javascript, and HTML5

By

Linux Command Line Utility: “Screen”

I was having problems today when trying to build a package on my home Linux box, and the Putty ssh client was timing out on me, despite a KEEP_ALIVE setting of 60 seconds.

Thanks to Splatypus in #gentoo on irc.freenode.net, who told me to use “screen”. of course I had no idea what they meant, so they gave me the link to the project page on Freshmeat.net. From there I found the official gnu screen page, and then a quick search turned up a nice screen tutorial and developers project page.

The screen tutorial was a little intimidating at first, but after playing with it, I finally got it. The notation behind “screen” is that you can login via ssh to your server (start ‘screen’), then create “windows” inside the shell, and then detach them from the current ssh session. Logout, and then reconnect anytime from anywhere later, and run ‘screen -r’ to reattach all the windows to the current shell.

This is great, because I kicked off a build from a regular old ssh shell in Putty, and the darn thing timed out 2.5 hours into it. Now I can just detach the window, and reconnect at anytime later, preserving the output, state, etc.

You can also name your windows, and list them so you can see what all you got going on.

An excellent tool, and a must have for remote admins.

  • Anonymous

    hi,
    i have been confused with installation of screen on cobalt raq4r. could someone be that kind and give me a more detailed instructions on pre- and postinstall configure.
    your help is highly appreciated.
    thank you.

  • http://www.blogger.com/profile/4688352 chovy

    Yup, i’m sure it’s been around for awhile. I love *nix, because everytime I run into a problem, there’s always a solution I’m unaware of.

  • Anonymous

    I’d just like to point out that as great a sreen is, it’s not exactly new. screen/mscreen and various other like named commands have existing from very early on with UNIX. Remeber dumb terminals, well you wouldn’t want to be limited to one session on a dumb terminal – hence screen utility.

    UNIX priciple – if you cna think of it, its almost sure to have been done and there’s a utility to do it with.

    May UNIX rule forever

  • http://www.blogger.com/profile/4688352 chovy

    I’m not sure if it’s irssi related or not, I do get some weird things happening when I don’t use a screen window after a long time. Like 1 day.

    I’ll try to describe it better next time it happens. It’s like the shell was voided or something. It seems transparent, except in the case of irssi the program is ended.

  • http://www.blogger.com/profile/7573782 eutopion

    That sounds pretty weird, and hasn’t happened to me. Are you sure that it’s because of screen? I would try to use it normally for a while and see what happens.

  • http://www.blogger.com/profile/4688352 chovy

    IRSSI seems to disconnect after awhile when I use screen. Anybody else have this problem?

  • http://www.blogger.com/profile/7573782 eutopion

    “screen” is awesome. It’s ideal for staying connected to IRC from multiple computers or places. I have irssi running on my Linux box all the time in a screen session and never have to miss a private message or conversation.

  • http://kott.itsuperhero.com Dutch Rapley

    Hey, I found you blog of a comment you made on Russell Beattie’s site. I noticed you found screen. I found it a couple of days ago too It’a nice little app.