Revision 4 as of 2007-05-03 00:24:39

Clear message
Edit History Actions Discussion

Howto/Screen

Screen

Screen is a great tool which has many uses. You could think about it as a kind of a window manager for your console.

For example, if you wish to run a command that will take time to finish, but at the same time you don't want to open more connections to your shell to do other things while the first command is running. Screen to the rescue.

Starting, detaching and reattaching a screen session

To start a screen session, simply type:

screen

This will spawn a new screen for you, and you should notice.. nothing at all. It should look like a regular login, but this time it is running inside a screen. Start your command, and let us say that you wish to go back to the console you launched screen from. To do this, simply enter the key combination of Ctrl-A, D (that is Ctrl-A followed by a D). Now your command is running in the background, inside your screen. To bring the running command to the foreground again (reattach), type:

screen -r

The next step

To make things a bit easier there is a few hints. If you want to run multiple commands at the same time and still be able to have a free console, you can do it in a few ways. You could detach from the running screen and create a new one from which you launch your second command. If you opt for doing things this way, you want to start your screens with the -S flag and a name for your screen, like this:

screen -S emacs

This will create a new screen with the name emacs. If you have several screens running in paralell, naming them will make your life a whole lot easier. To reattach a particular named screen, run:

screen -r emacs

The other way is to create a new window inside your screen. This is done by the key combination Ctrl-A, C. (C for Create). You should be presented with a brand new window. To step between windows inside your screen, press Ctrl-A, <space> for stepping forward, and Ctrl-A <backspace> for stepping backwards. You may also also use Ctrl-A <0-9> where the number is the window you want to visit.

Exiting

To end your screen session after all your commands has finished, simply logout or exit from within the screen, as you would do when you exit your regular shell. Screen will say

[screen is terminating]

and you will be left back at where you launched or reattached the screen from.

Have fun!

More

  • ["FAQ/DeadScreen"] - What to do with "dead screens".