Screen is a very useful utility program that are able to multiplex multiple terminal sessions in a single terminal session.

For instance if you are logged in to a remote terminal via SSH it is easy to create sub-sessions without logging in to an extra terminal. In the example below I;

  1. login to a remote host remote.host.org as user user
  2. start a new screen session named A
  3. _c_reate a new sub-session
  4. switch to _n_ext session

as follows

ssh user@remote.host.org
screen -S A
C-a c
C-a n

Another very useful feature is the possibilty to start screen in "detached" mode. This means that you can start a time comsuming tast on a remote machine. Log out. And the attach to the same session again.

In the example below I;

  1. create a new screen running script.sh in _d_etached mode using UTF-8 character set with name set to A.
  2. attach to screen named A to check status of script.
  3. detached again from within screen

as follows

screen -dm -U -S A ./script.sh
screen -dr A
C-a d

To clean up old screen windows do;

screen -wipe
pkill -9 screen

See screen(1) for details. Also see article Staying alive with screen.