Maintain Persistent Screen Connection

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.

Getting Started

  1. Start your screen session also known as a window

     
  2. In the event you loose connectivity simple ssh back into your server and reconnect to your screen session.

     
  3. One of the added benefits is that you can have multiple windows running during your terminal session.

  4. To display how many screen sessions you have running type the following command.

    screen session

    • 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.

  5. Reattach to screen session.

     

 

Additional commands:

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

 


Share:

Leave a Reply