Here's a visual tour of how screen works.

First, we start with a regular shell, like this:

Then we type screen -- and nothing seems to happen! Well, you might get a screen splash page, but after you press space it'll end up looking like just another empty terminal.

(I changed the color scheme just so we can distinguish what's the original shell and what's the Matrix, I mean, the screen session. They can be tricky to keep straight at first.)


Now, the useful thing about a screen session, is that you can "clone it." The way you do that is by sending a special command to screen.

That command is Ctrl-a c

There is very little visible information from screen itself. In fact, even the commands that you send to screen are invisible -- they all begin with Ctrl-a, and that won't print out to your terminal.

Anyway, you can repeat that previous step as many times as you like. (One way to think about it is that each new shell is rather like a tab in a web browser.)

In each shell, you can start different processes. Let's imagine we have three shells going in our screen session:

So here I started a process in the first shell, Then I created a new shell with Ctrl-a c, and ran another process, python, and another shell with Ctrl-a c then another process, perl

All three processes are now doing their thing simultaneously, just as if I'd started up separate terminals to run each of those processes indidually.

If I want to go back to the first shell and see how is doing, I can use another screen command: Ctrl-a space, to toggle through the shells in the screen session (it works like alt-tab in most window managers):

Now, we have all the stuff running that we want to be running. How do we leave the screen session and get back to our original shell? Ctrl-a d, for "detach." We leave all our Matrixy screen processes behind and go back to the mundane world where we started:

Now, the point of all this is, that screen process is still there and it's still doing whatever it was doing. That's why screen is useful: if you have a bunch of processes that take a long time to run, you can start them in a screen session, and you can "detach" from that set of processes, and then you can let them do their thing quietly in the corner.

In fact, you don't even have to be on the same machine. The white terminal we started with, for instance, could very well have been an ssh session. We ssh into the server, start our screen session, start our processes, and then log out of the server.

And the processes are still going.

Now, the real magic: we can reconnect to that screen session, like so: