Screen is the bomb

I started using screen about 4 years ago, and I think it's one of the best things ever. It is a tool available on linux that allows you to have multiple sessions, and you can "tab" between them with keyboard shortcuts. Here are some pros and cons:

Pros:
* You can log the output of each "window"
* You can rename windows (the default is 0, 1, 2....)
* You can detach and reattach to a screen.
* You can allow others to attach to your screen, so you work remotely and see the same thing.
* You can ssh into other boxes and attach to the screen running there. (This gets confusing, but it's pretty sweet)

Cons:
* You can't scroll up in each window. You have to enter a special "Copy Mode." This is a bummer when tailing logs
* The keyboard shortcuts are hard to remember at first
* Everyone in a while I get stuck in some sort of feature I have no idea how to get out of..... I guess I could read the man page, but I usually just ssh in a new terminal window and reattach.

I think the best part is that detach/reattach feature. I always use screen when doing production deployments. I can have all app servers open and ready to go. I usually have one as root to restart services, and another with quick access to the database. Let's say I accidentally unplug my internet connection during a deployment. It doesn't stop the deployment, so I can ssh back in, and quickly reattach to my screen, and pick up where I left off.

My advice is to use screen. Make sure to read the man page. The best piece of advice is to have a consistent layout of what you do in each of the windows. If you don't name them, and access them by number it's best to already know what's in window 1 vs 2. This is the trickiest part of using screen.

The basics:
* All commands are accessed with Ctrl-a - then the key for your action.
* To start screen just type "screen"
* To detach, type Ctrl-a-d
* To reattach, type "screen -r"
* A new window: Ctrl-a-c
* To list windows: Ctrl-a-w
* To switch to a window Ctrl-a-1 (to go to window 1)

Related posts:

  1. Touch Screen Kiosk in Adobe Air
  2. AJAX, Google and Screen Scraping
  3. GWT+ IntelliJ Productivity Tip
  4. Adobe “Open Screen” is not “Open Source”
  5. the iPhone and Touch screen technology

Comments: 5 so far

  1. I agree, screen is great! Opening an ssh connection to a remote box and then just opening new terminals in screen is so much easier than opening a whole bunch of terminals locally and then ssh-ing with each of them. The whole detach/reattach thing is great too for flaky connections.

    Comment by Jonathan, Wednesday, July 8, 2009 @ 7:04 pm

  2. It’s a feature. If you get stuck, you have probably pressed ctrl-s (freeze). Try pressing ctrl-q to unfreeze. Check http://munkymorgy.blogspot.com/2008/07/screen-ctrl-s-bug.html for more info or google “ctrl-s freeze”.

    Comment by Pauli Borodulin, Thursday, July 9, 2009 @ 12:24 pm

  3. I fell in love with Screen a while back, but somehow ended up not using it any more. Reading this reminded me of its awesomeness.

    When I do run screen, I set it up with the following configuration…
    http://raykrueger.blogspot.com/2006/12/using-screen-on-linux.html

    Comment by Ray Krueger, Thursday, July 9, 2009 @ 2:46 pm

  4. OMG! That config is wicked awesome. That has saved me tons of Ctrl-a-w
    Thanks Ray, and thank you linux geeks…

    Comment by Jason Sendelbach, Friday, July 10, 2009 @ 8:31 am

  5. This must be the most concise and useful screen tutorial ever :-) . Thanks for sharing!

    Comment by Emmanuel Oga, Saturday, July 18, 2009 @ 3:20 am

Leave a comment

Powered by WP Hashcash

Launch: Pathfinder Newsletter

    Get a monthly update on best practices for delivering successful software.

    Subscribe via email


    Subscribe via RSS      RSS icon

Topics

Search

WordPress

Comments about this site: info@pathf.com