How to use screen sessions in linux?

Step 0: Check if screen is installed

screen

If not run

sudo apt -y install screen

Step 1: Create a screen session with a meaningful session name

screen -S sessionname

Step 2: Check if you are in a screen session

$ echo $STY

If the result is something like this:

941609.sessionname

you are currently in a session.

Step 3: Exit and terminate screen session

$ exit

Step 4: Exit and keep screen session running (detach)

$ screen -d

Step 5: See existing screen sessions

$ screen -ls

Step 6: Reattach to existing screen sessions

$ screen -r sessionname