Kevin Kempf's Blog

January 18, 2011

Using screen to make your life easier on Linux

Filed under: Linux — kkempf @ 3:32 pm

An oldie, but a goodie

There’s nothing new about the steps outlined in this posting, but it’s so valuable, I thought I’d mention it.  It goes along with the classic mantra of work smarter, not harder.  In order to use it, you have to basically remember 3 things:

  • screen          to enable screen
  • screen -ls    to display available screens
  • screen -r      to reconnect to an existing screen

A typical maintenance scenario

I’m sitting at home, VPN’d into the office, trying to cram as many patches and maintenance pieces into a 4 hour windows as possible, once a month.  For the sake of a clear example, lets say I’m running adpatch via ssh, applying some 300mb fix to HR.  Suddenly the VPN connection hiccups (Windows 7!  never!) and no matter how many times I hit enter, the SSH session does nothing.  So where am I at?  Where’s my patch at?  Sort of an unknown.

Bring on screen

There’s a really simple solution to this if you’re running Linux.  Type screen before you start any work:


For demonstration purposes, a hard close

What screens are available on the host?

Assuming you’ve reconnected your ssh session, type screen -ls (fairly intuitive) and it will display your PID and a unique connection descriptor.  Use screen -r PID descriptor to reconnect to the existing session.

And finally, pick back up where you left off


Blog at