## Using the screen program

The "screen" program can be used whenever you want to log out of a remote Linux account, but you want another program that you are running (in our case, Avida) to keep running even after you've logged out. You may not need to use this immediately, but its good to know that its available. Screen is basically a virtual terminal -- you start it up, and it looks like the same terminal as before, but now you can "detach" it and "resume" it later. This is best shown by a demonstration.

### Screen Walkthrough

To start the screen program, simply type

`screen`

from the command line. You should see your command line prompt appear on a nice empty screen. Next, go into your avida work directory and start a run. If you put avida in your home directory, you would type:

`cd ~/avida/current/work/`
`primitive`

Now once the run is going, you want to detach it. Screen intercepts CTRL-A whenever you press it, and waits for the next keystroke to find out what it should do. Watch out because this may be confusing if you are using another program that you intended the CTRL-A to affect. In any case, to detach the screen, you should press CTRL-A followed by the lowercase letter 'd'. (note that you press one, and then the other, not all at once).

`[CTRL-A] d`

The avida run should disappear, and you should be back at the command line where you first ran screen, and now it will say "`[detached]`" at the bottom of the screen.

You can even log out and log back in now if you like. Whenever you are ready to get back to your avida run, from the command line, type:

`screen -r`

This tells screen to resume where it left off before. Notice that updates have continued to go by in Avida while you weren't connected.

There are two ways of issuing commands to screen. The first, we've already explained -- when you are in screen, you simply press CTRL-A and then the key that corresponds to the command you wish screen to perform. The second way is when you're not in screen. Then you need to type "`screen`" followed by a dash ('-') and the letter that corresponds to the command.

For example, imagine that I start up an avida run in a screen session, but I forgot to detach it before I went home. Now that I'm home, I want to see how my avida run is going. What I can do is log onto the remote Linux machine from home, type "`screen -d`" at the command line, and my screen session running elsewhere one that remote screen will detach. I can now type "`screen -r`" from where I am, and I'll be back in my screen session.

This explanation just touches on some of the abilities of screen. In practice, I tend to run a screen session an do much of my work in it. Then when I want to work somewhere else, I don't have to setup everything all over again -- I resume my screen session and I'm already right where I left off.

Below, I will go into some of the other abilities of screen.

### Screen Command Summary

Below is a list of commands that you can issue from within screen. Press CTRL-A and then the corresponding command key to get the effect.

d | Detach the current screen session
c | Create a new screen session. This new session will give you a brand new command line. You can have up to 10 screen session at a time.
[SPACE] | Toggle between screen sessions.
k | Kill the current screen session (but leave the rest running)
? | Get a list of all possible screen commands.

If you want to get to the official documentation that comes with screen, you should go to the command line and type:

`info screen`

You can then use the arrow keys to move the cursor around on the screen, and press enter on a link to obtain more information on a topic.

Project hosted by: