Skip to content

Instantly share code, notes, and snippets.

@KowalskiThomas
Created January 9, 2019 08:53
Show Gist options
  • Save KowalskiThomas/ef611d2353635e0549a6364389ec7059 to your computer and use it in GitHub Desktop.
Save KowalskiThomas/ef611d2353635e0549a6364389ec7059 to your computer and use it in GitHub Desktop.
Screen Guide

Screen allows you to have a headless terminal running in background.

Creating or reconnecting to a screen

To create or reconnect to a screen, use

screen -R <screen name>

That will create the screen and attach it. You're now in it.

Using the screen

Once you're in a screen, you can use the same commands as in any other terminal :

python3 main.py

And you will see their results in the screen.

Detaching from the screen

Once you've launched your task, you can detach from the screen so it keeps running in the background but without needing an open terminal by using the keys Ctrl + A, Ctrl + D (in sequence).

Listing existing screens

If you've forgotten the name of your screen(s), you can see a list of them by using

screen -ls

Which will show something like

There are screens on:
	28358.games	(01/06/19 20:13:47)	(Detached)
	10685.proxy	(12/29/18 20:08:47)	(Detached)
	22174.sb	(12/22/18 16:42:39)	(Detached)
	22142.sa	(12/22/18 16:42:22)	(Detached)
4 Sockets in /run/screen/S-kowalski.

Killing a screen

If you want to kill an existing screen (from inside of it), use the following keys combination :

Ctrl + A, Ctrl + K, y (in sequence)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment