SCREEN - Introduction

Please read this before you start SCREEN! It probably helps you get started a lot faster than with reading the manual. ;-)


Notation of Keys

Before we can really start off you need to know how characters and keys are denoted: (experienced users are asked to use this notation to clarify their answers on the mailing list and usenet.)

The "command character" (aka "escape character") notifies SCREEN to take the next character as a command. Commands are therefore given by a sequence of two keys: The command character followed by another key, eg 'w'.

The default command character is "control-a" which is also denoted by CTRL-A or c-a or ^A for short.

The second character usually is a letter (both lower case or upper case), a digit, or a punctuation sign ("?\',.<>{}[]-+").

The second character is "bound" to a "command name" which can also be entered on SCREEN's "command line" (more about this later).

These two letter sequences are described by "X Y" where X is the escape key" and Y is the "command key". Example: "c-a ?" So the question mark is actually bound to the "help" command which shows a table of the current key bindings and thus is the command you should remember from now on!

To enter a command on the command line, you type "c-a :" (a control-a followed by a colon) and then the command name and enter. Example: "c-a :help" You can "bind" keys to command names yourself - either directly on the command line or through the setup file.

But before configuring the setup you should first learn the commands and their effects by taking the following tour.


SCREEN FAQ

Some FAQs (frequently asked questions) and answers:
What is "screen"?
"screen" is UNIX program. It manages windows for terminals.

How many windows can you manage with screen?
SCREEN allows you to handle fourty windows by default. Each window has its own number. The first ten windows are numbered from 0 to 9 so you can easily access them by typing the corresponding digit after the command character. Jumping to windows with a higher number is easier using the "windowlist" command.

How do I use screen?
Starting up SCREEN is as easy as typing "screen" at your shell prompt. SCREEN will start up showing you one window (window "0") with a shell in it. You can now give commands to screen or to the process within your windows.

Which commands are available with SCREEN?
Take a look at the help screens with the command "c-a ?". These list the command names and their current bindings to keys.

Should I enter commands as names?
Entering commands via the command line is possible, but usually you will want to enter commands as fast as possible, so you should get to know the bindings/shortcuts first.

How do I create a new window?
To create a new window with a shell in it use either of the commands "c-a c" or "c-a c-c". the default commands are given such that you can use a letter or control-letter for the same command. this allows to leave your finger on the control key and yet not make a mistake by that. of course you can also give the command via the command line and enter ":screen" - but this takes more keystrokes, obviously.

How many screens do I currently use?
Use the command "c-a w" (":windows") to see a list of your windows. the list will be displayed at the bottom of the current screen for a few seconds (the duration can be adjusted).

How can I switch to another window?
You can switch to a window directly (a "jump-to") or "cycle" through the window list both forward or backward.
Window jump-to:
Use the command "c-a digit" where "digit" is the number of the window. Use the command "c-a w" (":windows") to see a list of your windows at the bottom of the front screen.
Window cycling:
Window cycling forward: Use the command "c-a n" (":next") to jump to the "next" window. The "next" window is the window with the next higher number. If there is no window with a higher number then the window with the lowest number will be used.
Window cycling backward:
Use the command "c-a p" (":prev") to jump to the "previous" window. The "previous" window is the window with the next lower number. If there is no window with a lower number then the window with the highest number will be used.

How can I change the title of a window? [980910]
Use the command ":title" (default: 'A') to change the title of a window.
Example: "c-a : title newtitle" changes the title of the current window to "newtitle".
Of course it is much quicker to use "c-a A" to use the "title" command.

How can I give a window a different number? [980910]
Use the command "number" to give the current window a new number. Example: "c-a : number 3" will give the current window the number '3'.
Note: If there was a window with the number '3' already then the current window will swap its number with the window with that number.

How do I get rid of a window?
To close a window you should simply end all the processes which you started from within the window, usually ending the last started process first.
As the default process started within windows is your shell, simply type "exit" to end it. Most shells also allow termination with a 'c-d' but this may depend on a setting for that shell.
On most terminals, the key 'c-s' has the functionality to "stop" the terminal, ie all output is queued until you "start" it again (usually ith 'c-q'). See the output of "stty -a" for these keys.
And some processes cannot be ended with a command, so you might have to "interrupt" them using the "interrupt key" (see "stty -a"); this signal is usually bound to the key 'c-c'.
If all of these do not work then you can send the processes signals using the command "kill" - but do not use this if you do not know what you are doing with it. See "man kill" for more info first!
As a last resort, you can use SCREEN's built-in command "kill" to "kill" a window. But beware - you will kill the main process of that window and all "children" of that process die with it.
You can also "kill" a window with the command "c-a k" (":kill"). But you should make sure that this won't cause any harmful effects.
How do I quit screen?
Screen quits automatically when there is no more window to be managed. This happens when the process of the last window ends. So to quit you must end all running processes which were started.
Now that you know how to kill a window (you did read the previous FAQ on how to "close a window", didn't you ;-) let me tell you that there is a command kill the main screen process, too. This will kill the complete session - "no questions asked". But this is very dangerous as you might lose unfinished work. I do not recommend you use this command so I won't tell you about it. Please RTFM to find this command yourself.

However, there is another method to "quit" the current session: "detaching".

Why should I "detach" a session?
Detaching a session is like putting down a book - you remove it from the view and put it onto a table. You can regard this as a "detached book". Later on, when you want to read it again, you "reattach" to it. But the difference here is that with a detached session you end the main process of SCREEN, (yes, a screen session consists of *two* processes - it's a tech thing ;-) allowing you to return to your login shell and log out; however, your other SCREEN process continues to keep the programs you have started *alive* while you are away (logged out). So you can leave your set of started programs running, eg your editor, mailer, newsreader, shell, webbrowser, and possible your ftp client that downloads some file, and your irc client to keep listening to a channel. After a reattach you can continue using the processes running within the windows.
The command to detach the current session is "c-a d".

What do I do with "detached" sessions? - Reattach!
To gain control over a detached SCREEN session, tell SCREEN on the command line that you do not want to start a new session but "reattach" to a running session instead.
But before reattaching you should check the list of running SCREEN sessions:
        $ screen -ls
        There is a screen on:
                6467.ttyp0.gauss        (Detached)
        1 Socket in /home/emailer/guckes/.Screens.
The number "6467" is the process number of the SCREEN process that keeps the session alive, "ttyp0" is the name of the actual "terminal" that the session sends its output to, and "gauss" is the name of the host running the SCREEN process, so you'll know where to look when you request this info from another host within the domain (very useful!).
As there is only one detached session on the current host, you can now reattach to it with the command line switch "-r".
        $ screen -r
Now you should be back with the running session and you can continue your work. :-)


Problems and Solutions

i am sure you already have some questions. some of these come quite naturally. here are some and their answers:

Window Titles

Let's assume that your SCREEN session consists in three windows - one for your shell ("shell") and two others where you have started your editor ("editor"). Thus the SCREEN command ":windows" (^Aw) shows you this:
        0 shell 1-editor 2*editor

Non-Unique Window Title
Q: How do I tell the two windows with the same title apart?
A: Change the title of one window!

The following question thus comes quite naturally:

Window Title Change
Q: How do I change the title of a window?
A: Use the SCREEN command "title" to change the title of a window:
        :title
The screen will prompt you with:
        Set window's title to:
Now type in the new title, eg "edit2". Then the :windows message will show you
        0 shell 1-editor 2*edit2
Note: The command "title" is bound to command key 'A' by default. So typing c-a A should give the same result.

Session Password

You can set an internal password for yuor session with :password. After you lock your session with :lockscreen the screen will show your user name and user id and a prompt for the password:

      Screen used by Sven Guckes <sven>.
      Password:

Mind you, this prompt ask for the user password!

If you have set a password for the *session* then you will gte *another* prompt *after* you have typed it the account password:

      Screen used by Sven Guckes <sven>.
      Password:
      Screen password:

*Now* type in the *session* password.

FAQ:  How do I get rid of the session password?
A:    :password none