Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells). There is a scrollback history buffer for each virtual terminal and a copy-and-paste mechanism that allows moving text regions between windows.
When screen is called, it creates a single window with a shell in it (or the specified command) and then gets out of your way so that you can use the program as you normally would. Then, at any time, you can create new (full-screen) windows with other programs in them (including more shells), kill existing windows, view a list of windows, turn output logging on and off, copy-and-paste text between windows, view the scrollback history, switch between windows in whatever manner you wish, etc. All windows run their programs completely independent of each other. Programs continue to run when their window is currently not visible and even when the whole screen session is detached from the user’s terminal. When a program terminates, screen (per default) kills the window that con‐tained it. If this window was in the foreground, the display switches to the previous window; if none are left, screen exits.
In simple words, screen is a tool that will help us to maintain multiple sessions of ssh without disturbing each other.
On CentOS Linux, you can install “screen” using Yum:
yum install screen
On Ubuntu-based servers, use “apt-get” to install “screen”:
sudo apt-get install screen
Starting a Screen
You can start with ” screen ”
Or you can name it with:
screen -S SCREEN_NAME
Now you will be in that session, run your commands, and then close the terminal. When you are back open the terminal and run:
it will list all the active screen sessions and you can choose to which one you need to login to using this command:
screen -x SCREEN_NAME
Screen is an ideal tool when you have a choky internet connection of you are doing a task which is going to take long and you need to travel in between or if you have a screen session, it is easy to escalate issues or you can just port the ssh session to some one else who need to work on the task.