Hostwinds Tutorials

Search results for:


Table of Contents


Getting Started
Additional commands:

Maintain Persistent Screen Connection

Tags: VPS 

Getting Started
Additional commands:

If you have a VPS, 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 the loss of connectivity. This is a problem, especially if you happen to be in the middle of a large task where you end up losing whatever 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 to lose connectivity and resume later, allowing you to pick up where you left off.

Getting Started

Start your screen session, also known as a window

screen

If you lose connectivity, simply ssh back into your server and reconnect to your screen session.

screen -r

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.

screen -ls
  • 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

Additional commands:

Ctrl-a c Create a 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

Written by Hostwinds Team  /  April 10, 2018