Skip to content

Instantly share code, notes, and snippets.

@drewlesueur
Created May 1, 2011 02:26
Show Gist options
  • Save drewlesueur/950187 to your computer and use it in GitHub Desktop.
Save drewlesueur/950187 to your computer and use it in GitHub Desktop.
How to use linux screen

Also see http://magazine.redhat.com/2007/09/27/a-guide-to-gnu-screen/
and http://www.gnu.org/software/screen/manual/screen.html
and http://arundelo.livejournal.com/390.html

how to use screen

the hierarchy of screen goes like this sessions > windows

You can create new sessions and put windows in it.

I am going to make an example of me working on two projects. These projects are my screen sessions.

For each project I want 3 windows -- vim window, a window to compile coffeescript and a window to run the server

My first project is a called cartoonmaker, and my second project is called musicmaker

I will first create a session for cartoonmaker

screen -S cartoonmaker

Now I have one window inside cartoonmaker

In this winodw I will compile my coffeescript coffee -cwb public/*.coffee

Now I want another window to run my server. I create a new window by Ctrl a+c

I will start my server via supervisor app.coffee

Now I want another window for vim. I Ctrl a+c agian. and then vi public/index.coffee

To toggle between windows in this session I can Ctrl a+n. Ctrl a+n is like alt tab in windows (kind of --see below).

To close a window I can either Ctrl d out of it or Ctrl K out of it


Now I want to detach from that session and create a new

To detach from the session I am in I Ctrl a+d

Now I am in my main bash.

I start a new session like last time screen -S musicmaker

I use Ctrl a+c to make new windows

I use Ctrl a+n to toggle between windows

I Ctrl a+d to detach again

To go back to a screen session, like cartoonmaker I screen -x cartoonmaker

to see a list of sessions to screen -ls

1870.cartoonmaker (05/01/11 03:44:24)
1870.musicmaker (05/01/11 03:42:21)

Here are some other helpful commands while you are in screen

all are prefixed with Ctrl a

  • 0 through 9 – Switches between windows
  • Ctrl n – Switches to the next available window
  • Backspace – Switches to the previous available
  • Ctrl a (again) – Switches back to the last window you were on
  • Ctrl g - Toggles the visual bell. (wuff -- wuff)
  • A – Changes window session name
  • K – Kills a window session
  • c – Creates a new window
  • [ - Then use arrows to scroll up and down terminal
  • C - Clear the screen
  • " - nice ui for choosing windows
  • ' - name of window ?

also see http://aperiodic.net/screen/quick_reference

http://www.debian-administration.org/articles/34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment