Thursday, August 19, 2010

Screen Command

Screen has two main functionalities:

- Run multiple terminal session within a single terminal.
- A started program is decoupled from the real terminal and can thus run in the background. The real terminal can be closed and reattached later.

How to install?
#yum install screen

start screen with:
# screen

Within the screen session we can start a long lasting program (like top). Detach the terminal and reattach the same terminal from an other machine (over ssh for example).
# top
Now detach with Ctrl-a Ctrl-d. Reattach the terminal with

# screen -r
or better:
# screen -R -D

Attach here and now. In detail this means: If a session is running, then reattach. If necessary detach and logout remotely first. If it was not running create it and notify the user.
Screen commands (within screen)

All screen commands start with Ctrl-a.
* Ctrl-a ? help and summary of functions
* Ctrl-a c create an new window (terminal)
* Ctrl-a Ctrl-n and Ctrl-a Ctrl-p to switch to the next or previous window in the list, by number.
* Ctrl-a Ctrl-N where N is a number from 0 to 9, to switch to the corresponding window.
* Ctrl-a " to get a navigable list of running windows
* Ctrl-a a to clear a missed Ctrl-a
* Ctrl-a Ctrl-d to disconnect and leave the session running in the background
* Ctrl-a x lock the screen terminal with a password

The screen session is terminated when the program within the running terminal is closed and you logout from the terminal.

No comments: