Thursday, January 24, 2013

screen -- a terminal based window manager

Screen is a window manager that multiplexes a physical terminal between several processes. It allows users to run several interactive shell processes within one physical terminal. A subtle application of screen is that it enables processes running despite a dropped connection.

The command screen creates a single window with a  shell and then gets out of our way so that we can use the shell as we do normally.

Everything we type is sent to the process running in the current window, except for one keystroke that is used to initiate a command to the window manager. By default, each command begins with a control-a (Ctrl-a), and is  followed by one other keystroke. The most important screen commands that we needs are:
  • Ctrl-a c -- create a new window and switch to that window
  • Ctrl-a w -- show a list of windows
  • Ctrl-a n -- switch to the next window
  • Ctrl-a p -- switch to the previous window
  • Ctrl-a 0 -- switch to window number 0
  • Ctrl-a 9 -- switch to window number 9
  • Ctrl-a d -- detach screen from this terminal

To detach a screen session and return to your normal terminal, type:

Ctrl-a d

All processes (in the screen session) continue to run when screen is detached from the user's terminal.


To get a list of your current screen sessions, (in your normal terminal) type:

screen -ls


In case there is only one screen session, you may reattach to it by typing:

screen -r


In case there are more screen sessions running, you should specify which session to reattach by typing:

screen -r [[pid.]tty[.host]]

where [[pid.]tty[.host]] is the session information obtained by command screen -ls

No comments:

Post a Comment