Several times I have encountered a situation where I was doing remote SSH to VPS for installation and configuration suddenly the internet connection had a problem and the SSH connection was lost. Well, the previous process was not known where it was or could not continue the previous session. To solve a case like this, there is a utility program called screen.
By using screen, a sysadmin can create multiple terminals virtually in one screen, can switch virtual terminals, and when an SSH connection is lost, they can resume or reopen a virtual terminal that is still running.
Install screen on Debian/Ubuntu.
sudo apt install screen
Install screen on CentOS/Fedora.
sudo yum install screen
sudo dnf install screen
For example, if you want to update, create a new screen with the name update.
screen -S update
After running the command above, it will go directly to the screen (Attached). If you want to temporarily exit the screen that is currently active (Detached), for example when the update process is running you want to do another configuration, press CTRL + A then D, and a message will be displayed:
[detached from 15321.update]
Create a new screen named config.
screen -S config
Display all available screens with the option -ls.
There are screens on:
15525.config (11/07/20 08:32:17) (Attached)
15321.update (11/07/20 08:29:58) (Detached)
2 Sockets in /run/screen/S-musa.
To re-enter the update screen use the -r option followed by a screen name or screen id number.
screen -r update
screen -r 15321
Permanently exiting the screen type exit or CTRL + D. A message will be displayed:
[screen is terminating]
If you enjoy what I do, please support me on Ko-fi! https://ko-fi.com/musaamin