If you have a VPS then it is possible that this did not come with a user interface and you are using the command line interface. This means that you are most likely using SSH to connect to your VPS. One of the risks that you run during your remote terminal session is loss of connectivity. This is a problem especially if you happen to be in the middle of a large task where you end up loosing what ever you were working on at the time. The screen application helps mitigate any connection issues you may run into. By running the screen command you will be able loose connectivity and resume at a later time allowing you to pick up where you left off.
- Start your screen session also known as a window
- In the event you loose connectivity simple ssh back into your server and reconnect to your screen session.
- One of the added benefits is that you can have multiple windows running during your terminal session.
- To display how many screen sessions you have running type the following command.
- In the sample output above you see the screen id followed by the pts and hostname. With that information now we combine the two previous commands to reattach a window by appending the screen id to the end.
- Reattach to screen session.
screen -r 13458
|Ctrl-a c||Create new window
|Ctrl-a k||Kill the current window|
|Ctrl-a w||List all windows (the current window is marked with “*”)|
|Ctrl-a 0-9||Go to a window numbered 0-9|
|Ctrl-a n||Go to the next window|
|Ctrl-a Ctrl-a||Toggle between windows|
|Ctrl-a [||Start copy mode|
|Ctrl-a ]||Paste copied text|
|Ctrl-a ?||Help (display a list of commands)|
|Ctrl-a Ctrl-\||Quit screen|
|Ctrl-a D (Shift-d)||Power detach and logout|
|Ctrl-a d||Detach but keep shell window open|