If you are looking for a solution to continue running your Linux scripts/terminal sessions even after disconnecting from SSH, then “screen” is a perfect tool for you! Screen can be useful in many number of circumstances, such as if you want to start an installation or data transfer but wish to close your SSH connection and come back to it later.

Another interesting feature of screen is that you can also share the same session of yours with multiple users at the same time.

Now let’s jump into how to install and use screen on your Linux VPS!  The installation command will vary depending on the type of Linux OS you’re running, please see below:

Ubuntu/Debian

sudo apt install screen -y

CentOS/AlmaLinux:

sudo yum install screen -y

Launching a Screen Session

Managing screen is simple from your command line, when your typing screen for first time by entering the below command:

screen

That’s it – and your screen session is now ongoing.

To Detach a Screen Session

To detach a screen all you have to do just use Ctrl+A + D on your keyboard at the same time.

To List Screen

screen -ls

To Reattach

screen -r 2107078

In the above example we see that our screen session was running on ID 2107078, so we entered screen -r followed by the ID. The ID may vary in your environment, replace it accordingly.

Locking your Screen Session

For security purposes, you can lock your screen using Ctrl+A + X key on your keyboard at the same time (while in the current screen session)

This will lock your screen and when someone tries to access your screen, password prompt appears to enter password for accessing the screen.

To create a new screen while within an existing screen session, hit Ctrl+A + C at the same time on your keyboard

To go back to previous screen, Ctrl+A + P at the same time on your keyboard.

And just like that, you are now an expert in navigating screen on your Linux environment! We hope you’ve found this tutorial helpful.

Looking for an affordable VPS service, that is instantly set up? Consider RackNerd:
Instant Setup Linux VPS ->> https://www.racknerd.com/kvm-vps

Server Hosting Solutions by RackNerd:

Shared Hosting
cPanel Web Hosting in US, Europe, and Asia datacenters
Logo
Reseller Hosting
Create your new income stream today with a reseller account
Logo
VPS (Virtual Private Server)
Fast and Affordable VPS services - Instantly Deployed
Logo
Dedicated Servers
Bare-metal servers, ideal for the performance-demanding use case.
Logo

Leave a comment

Your email address will not be published.