GNU Screen Basic Tutorial

If you’ve ever SSHed into a server, ran something, logged off and got frustrated because whatever you were running stopped running because you had to change coffee shops or go to class then you’ve experienced the need for GNU Screen.

Put simply it allows you to maintain a persistent session, a terminal that does not change or quit just because you logged out.  Installation is easy.  On a debian machine its simply

sudo apt-get install screen

Usage is straight forward as well.  Type the word “screen”

$ screen

and you’ll be shown a welcome window, press space to get through.  Now you’ll simply see a standard shell.  You can execute whatever you want here and the session will not die until you tell it to.  You can start many different sessions and toggle between them.  Here’s a table of the basic controls for screen.

  • Ctl-a Ctl-c, create a new window
  • Ctl-a Ctl-a,  switch between windows
  • Ctl-a n, toggle to next window
  • Ctl-a p, toggle to previous window
  • Ctl-a 5, toggle to 5th window
  • Ctl-a “, get a menu listing all of the window
  • Ctl-a A, tool for adding a name to your window, helpful for the menu view
  • Ctl-a k, Kills the window
  • Ctl-a d, Detach from the session

Another thing to note.  Once you detach from a screen, you need to re-attache the next time you run screen.  To do that simply specify the -r parameter.

$ screen -r

Update 6-3-2009: A few fixes were made thanks to Ben Finney’s comments

  1. Ben Finney said:

    > Ctl-a Ctl-a, create a new window

    Nope. Ctrl+a Ctrl+a toggles to the “other” window (whichever one you were at previously). Ctrl+a Ctrl+c creates a new window.

    > Ctl-a “, get a list of all of the windows

    Even better than a list; it’s a *menu* of all windows, so you can interactively select one.

    > Ctl-a d, Detach from the window

    This command actually detaches the whole session, not just one window.

    Glad to see more awareness of GNU screen!

  2. rbp said:

    BTW, C-a 5 toggles to the *6th* window, since numbering starts at 0. Perhaps it’s less confusing to say “C-a 5 toggles to window #5”.

    Always good to see screen on the spotlight, thanks! 🙂

  3. clayton650 said:

    This is great… Thanks!!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s