GNU Screen: an introduction and beginner’s tutorial

Since I’ve gone minimal on my work and laptop desktop, I’ve discovered a program that is quite useful: GNU Screen.

I’ve heard about it in various forums, but didn’t know what it was about until I stumbled onto a well-written tutorial.

Screen is best described as a terminal multiplexer. Using it, you can run any number of console-based applications–interactive command shells, curses-based applications, text editors, etc.–within a single terminal. The desire to do this is what gets most people hooked on screen. I used to start a half-dozen terminal emulators when I logged into my machine: I wanted one to read my email, one to edit my code, one to compile my code, one for my newsreader, one for a shell into my web host, and so on. Now I start one terminal emulator, and run screen in it. Problem solved.

So I started experimenting with GNU Screen. Here are some key strokes that came in handy:

Navigating Through Screens

  • C-a c Create new screen window
  • C-a C-a switch between windows
  • C-a (num) go to numbered window
  • C-a n go to next window
  • C-a p go to previous window
  • C-a “ list windows in interactive mode
  • C-a A rename window
  • C-a K kill screen
  • C-a \ quit screen

Detach/Reattach Screen

  • C-a d detatch session
  • screen -r reattach session
  • screen -d -r reattach session, and if necessary, detach first
  • screen -x attach to non-detached screen…multi session mode
  • C-a d detach from multi session mode

Misc

  • C-a [ scroll up
  • C-a M start/stop monitoring
  • C-a _ monitor for silence
  • C-a ? help