Thursday 28 January 2016

GNU Screen how to

Overview

screen (GNU screen) is a software which is used to create virtual terminals. It can run on it's own when not under direct user control. This is especially useful while working with a remote system, when a disconnect can occur at any moment. In this case, the screen session will continue to execute and you may reattach a running screen later. 

I found it very useful in the cases where I need to run a script in a remote server which takes long time time to execute.

Installation

In a Debian based operating system it can be installed by this command:

sudo apt-get install screen

Basic Usage

Starting a new screen session:
screen -S <screen_name>
This command will start a new screen session. After running the process, the screen can be detached by pressing:
ctrl + a + d
All available screen can be viewed using this command:
screen -ls
Reattaching a screen can be performed by typing:
screen -r <screen_name>