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 screenOr 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.
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:
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
There’s lots of other commands you can use but the above will do most of the common elements of using screen.