Thursday, 20th November 2008
Screen is similar to the taskbar in Windows in that it allows you to leave process running in the background and switch between them without having to make multiple SSH connections.
$ screen -S [windowname] [command goes here]
# to create a screen with a given name running that application
The command is optional as a screen is just another shell instance and can be issued more commands just as though you had another SSH connection open - but without wasting the bandwidth on updating 2 windows at once.
$ screen -r [windowname]
# to resume/reattach the screen with given name
Press CTRL+A+D to detach the current screen (general use: will also log you out of whatever shell you're currently in).
$ screen -ls
# will list all screens belonging to you.
$ screen -wipe
# will clear your screen list of any defunct or dead screens.
The best way to understand how a screen works is to look at an example:
$ screen -S chicken_recipe vim chikin.book
# creates new screen session called chicken_recipe, within which chikin.book
is opened with vim
# If vim is closed, the screen will automatically terminate itself.
Another way of doing this would be:
$ screen -S chicken_recipe
# launches screen with name chicken_recipe
$ vim chikin.book
# opens chikin.book with vim
# if vim is closed, the screen will remain open and you will be faced with a
shell prompt
# to detach screens (does NOT close the screen) press Ctrl+A+D
$ screen -r chicken_recipe
# reattaches the screen "chicken_recipe"
As an alternative, drop the -S argument and the screens will be referred to by their TTY.
For more info type man screen into your shell.