How to do it: Using screen A simple beginners guide to the screen-command

An article, posted more than 10 years ago filed in tutorial, linux, server, introduction, ssh, unix, guide, debian, command line & how i do it.

A technical note to myself: One way of doing multiple things simultanenously on a server can be by setting up multiple connections via SSH, that’s how I used to do things before. An alternative is to use a single connection and use the command screen on the remote server. Another good reason to use screen is if you have a long running process that you don’t want to break just because your SSH connection flips on and off with your computer going in and out of stand-by.

This is for absolute beginners. If you don’t know about screen, this is for you. If you are already familiar with screen, I probably won’t be able to educate you :o

So what is Screen?

GNU Screen is a kind of window managment system for the terminal (you’re ought to say terminal multiplexer) and has several advantages over using multiple SSH connections. Most importantly: the processes keep running when SSH disconnects (although you shouldn’t think of it as a replacement for background processes (check init.d for these (for Debian based systems that is)).

How do I operate it?

I’m assuming you know how to connect to a remote server, and you have already installed, or are able to install screen (e.g. sudo apt-get install screen). So assuming screen is installed, to list the currently open screens enter:

screen -ls

Probably you won’t see any screens, and it will say something like ‘no sockets found’.

You initiate a new screen by simply calling screen without parameters (although you may want to use some additional paramters to give them names that you’ll be able to remember).

screen

You’ll see some licensing info and where to go for bugs. Hit space.

Now you’ll see a the prompt, as if nothing really happened. But really, something has. You’ll know that you’re attached to a screen when you enter the screen -ls command again.

Start whatever you want, and you’ll able to keep it running while doing something else after ‘detaching’ the screen by pressing Ctrl+A followed by the letter d (of detach).

Your now able to set up another screen by typing screen again and you’ve started another screen session and in case you want to attach again:

screen -x

Isn’t there more to this?

Well, I’ve just covered the very basics, but see: http://aperiodic.net/screen/quick_reference for a comprehensive quick reference for all the commands (were C-a == Ctrl+A), and learn e.g. about split screens (Ctrl+A, |; Ctrl+A, Tab; Ctrl+A, C) and more. Happy learning!

Op de hoogte blijven?

Maandelijks maak ik een selectie artikelen en zorg ik voor wat extra context bij de meer technische stukken. Schrijf je hieronder in:

Mailfrequentie = 1x per maand. Je privacy wordt serieus genomen: de mailinglijst bestaat alleen op onze servers.