it is a screen

Screen!?

This is actually notes I had from work. I will edit them to make them more friendly later. This guide really only works if you are SSH’ed to a server with screen installed.

Starting Screen and Making New Windows.  Invoking screen is pretty easy. To start it you type:

screen

After you invoke screen you may get a message that tell you about screen, just hit enter to continue. You may also just get the prompt which means you are running screen.

To do things like add window and use other functions of screen you will need to precede key strokes with Control+a. In the man page this is referred to as C-a. First things first let’s name the current screen we are on. Type the following

C-a A

Just to be clear, what you do is hit Control and A at the same time, then capital A (so shift and a). There should be a prompt at the bottom that reads: Set window’s title to: bash. Remove bash (or whatever the default entry is) and type “First” and hit enter.

Now let’s make a new window. Type:C-a C
Now you are in the other screen change this window’s title to “Second”.Moving Between WindowsNow that we have two windows let’s take a look at them. Type the following:C-a “
Now you see a list of windows. You can see the window number (which remember starts with 0 not 1) and it’s name. We are currently on window 1, let’s change to window 0. Type:C-a ‘
There is now a prompt that says Switch to window:. Type 0 and hit enter. You are now on window 0.Scrolling in ScreenIf you have a directory with lots of files in it, run a ls -lha on it. Try to scroll up to see the top, can’t do it. You can it’s just different. Type the following:C-a [
Now you have entered whats called “Copy/Scrollback Mode”. Use the arrow keys to scroll up and down. When you are done, hit enter twice to resume working with the prompt.

Detaching and Attaching Screen Sessions.

Detaching and attaching a screen session can be helpful in situations where you may need to run a repair script or a file operation that can take some time, detaching the session means that not only will the operation run, but someone can log into the server and check on the progress of the operation rather than just guessing it’s progress based on the process list.To demonstrate this, select one of your windows in screen and run top. Now type:

C-a d

At this point you are not using screen as you have detached it. At this point any other user can attach that session. Run the following command:

screen -D -R

If there is only one screen session that is detached it will open that session automatically, otherwise it will ask you specify one. Type the name of the session in and enter it, if it is the incorrect session, detach it and select another session.

Closing

There are two ways to close a screen session.

You can type exit when there is just one window open or if you have many open and you would like to close all of them:

C-a \

This will ask you to confirm with a Y or N. This should give you a good starting point for screen. If you would like more information always remember man screen and C-a ? are your friends.

Leave a Reply