Keeping SSH session running using 'Screen'

Screen is like a window manager for your console. It will allow you to keep multiple terminal sessions running and easily switch between them - much like the Mac OS and Windows 10 desktop screens. It also protects you from disconnection, because the screen session doesn’t end when you get disconnected - this is very handy if your connect gets borken pipes or unreliable connections.

To make sure screen is installed on the server you are connecting to use the following command:

sudo apt-get install screen
Or with CentOS 5+
sudo yum install screen

Now that screen has been installed you can create a new screen session by using the simple command below.

screen

To disconnect but leave the session running in the background:

Press Ctrl+A and then Ctrl+D. You will see the message [detached]

To reconnect to an already running session:

screen -r

To reconnect to an existing session, or create a new one if none exists

screen -D -r

To create a new window inside of a running screen session

Hit Ctrl+A and then C in immediate succession. You will see a new prompt.

To switch from one screen window to another

Hit Ctrl+A and then Ctrl+A in immediate succession.

To list open screen windows

screen -ls

There’s lots of other commands you can use but the above will do most of the common elements of using screen.

  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

rkhunter (Rootkit Hunter) Install Guide

What is rkhunterrkhunter (Rootkit Hunter) is a Unix-based tool that scans for rootkits,...

List of available VPS Templates

Below is a list of the available templates you can select to use on your Virtual Private Servers...

How to install a .bin file using SSH on Ubuntu/CentOS

Bin files are Linux self extracting binary files that is commonly used for server side software....

Can you install Zope & Plone CMS onto my VPS or dedicated server?

We can install and setup the latest Zope & Plone CMS onto any of our VPS or dedicated servers...