Search This Blog

Friday, November 30, 2012

Using GNU 'screen'

This is a quick-and-dirty GNU screen cheat-sheet


Start a screen session:
$ screen
(this will also open a window attached to the current screen)
You can also name a screen when opening it, which makes the re-attachment easier, specially if you use many screens simulatneously:
$ screen -S 

In a screen session you can work with multiple windows.

  • Open a new window: ctrl-a and then c
  • Go to the next window: ctrl-a and then n
  • Go to the previous window: ctrl-a and then p

Windows can be closed (killed) or detached. When detached, the process keeps running, but is not attached to the screen anymore. That way, when you quit the screen session, all detached windows will keep running any processes they were running (if you are working on a remote machine, you can logoff and they will keep running!)

Closing and detaching:

  • Close the current window: ctrl-a and then k
  • Close the screen: ctrl-a and then \ (note that this will kill all windows!)
  • Detach a screen session: ctrl-a and then d


You can list all the screens running in a machine (useful when leaving long processes running in remote machines):
$ screen -ls
(this will list all the screen sessions running, each one with a unique ID)

To re-attach a detached window:
$ screen -r <screen_unique_ID|screen_name>

If you need more help inside a window session: ctrl-a and then ?

A more comprehensive cheat-sheet can be found here.

Screen window as a login shell

Add shell -$SHELL to ~/.screenrc

3 comments:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here.
    Kindly keep blogging. If anyone wants to become a Front end developer learn from javascript and jquery training in chennai .
    or learn thru Javascript Training in Chennai.
    Nowadays JavaScript has tons of job opportunities on various vertical industry. javascript and jquery training in chennai

    ReplyDelete
  2. You have done really a superb job with your web site. Marvelous stuff is here to read.
    Gamesunblocked Unblockedgamesbeast unblockedgames77atschool

    ReplyDelete