Thursday, February 7, 2013

screen

I finally learned how to use screen, a terminal windowing program that can detach so its windows run as a background task. When you detach, screen returns you to your shell. Detaching allows me to start work on a server from my lab workstation in a screen session, detach screen, logout and turn off my workstation, go home, and resume the same screen session from home.

Start screen with
$> screen
Once inside screen, the windows act mostly like a terminal, but now you can issue commands to screen using Ctrl-a and a command key. The useful keys that I have been using are:
  • Create a window (Ctrl-a c)
  • Next (Ctrl-a n) or Previous (Ctrl-a p) window.
  • Detach (Ctrl-a d)
To start screen with a previously detached session, first find the session with:
$> screen -ls 
There are screens on:
    11999.pts-0.localhost    (Attached)
    17129.pts-3.localhost    (Detached)
$> screen -r 17129.pts-3.localhost
The -r flag resumes the detached screen session.

Detaching is useful especially for long-running programs or for conserving the state of many terminal windows.

No comments:

Post a Comment