Updated 2019-05-31

Screen Quick-Start Guide

What is Screen and what is it used for?

  • Screen is a "full-screen window manager"
  • Launching Screen starts a window - if your connection drops (due to intermittent WiFi, laptop losing power, or disconnecting from ssh), you can go back to exactly what you were doing because you were using a screen.
  • To help improve productivity and make sure your hard work isn't undone, use Screen!

Getting started

  • Screen sessions live on the server where they were started, so to run a remote screen during an SSH session, you should first log on to the desired node where you will be running your remote job.

Warning

Keep track of which login node you're working on - if you start a screen on login-s1, you will not be able to reconnect to it from any other login nodes (login-s2, login-s3, etc.)

  • To keep things tidy and maintain a single screen, type screen -D -R -S 'main'

Tip

You can add this command as an alias in your ~/.bashrc file for added ease. Simply add the following line: alias screen='screen -D -R -S 'main'. This will also reattach an existing 'main' screen if you forget about it!

  • Run your remote session as you normally would - if your connection is interrupted, you'll be able to login again and reconnect to the screen to continue your work
  • If you started a process and need to exit your SSH session, you can detach the screen by typing Ctrl+a, followed by d
  • Once detached, you are free to do anything else - if you want to reattach your screen, simply type screen -r.
  • If you have multiple screens running, you can check their status using screen -ls.
  • To completely terminate your screen session, end it with pkill screen.