. While that was for demonstrating how to multi-task on Linux, you can also use the screen to preserve your SSH sessions. It’s a fantastic benefit and one that propels screen to the top of any “must-have” utilities to use on your Linux server.<\/span><\/p>\nIn the screenshot below, I’ve initiated a process to sleep for 30 minutes and pushed it into the background:<\/span><\/p>\n<\/p>\n
Now I just close my SSH session. I don’t exit gracefully or anything. I just press the “X” at the top of the Window. When I log in again, my process has vanished. It no longer exists and was killed as soon as I closed SSH:<\/span><\/p>\n<\/p>\n
Now let’s try the same thing with screen activated. In the screenshot below, I run the <\/span>same<\/span><\/i> command, but this time inside a “screen” as shown here:<\/span><\/p>\n<\/p>\n
This is a new screen session, within screen “0”. Now when I close SSH and come back, I can get a list of all previous screens using the command:<\/span><\/p>\nscreen -ls<\/span><\/pre>\nAnd this gives me the output as shown here:<\/span><\/p>\n<\/p>\n
As you can see, there is a screen session here with the name:<\/span><\/p>\npts-0.test-centos-server<\/span><\/p>\nTo reconnect to it, just type:<\/span><\/p>\nscreen -r<\/span><\/pre>\nAnd this will take you back to where you were before the SSH connection was terminated! It’s an amazing tool that you <\/span>need<\/span><\/i> to use for all important operations as insurance against accidental terminations.<\/span><\/p>\n