Theme editor

Guide Linux Managing and Reattaching to a screen Session via SSH – Guide 2025

  • Thread starter Thread starter CL4Y
  • Start date Start date
  • Views 219

CL4Y

Keyboard Ninja
Administrator
Thread owner

Managing and Reattaching to a screen Session via SSH – Guide 2025​

When working on long-running commands, processes, or installations on a server, an unexpected SSH disconnection can interrupt everything. This is where GNU Screen becomes essential. With screen, you can run sessions in the background and reconnect to them even after a lost connection.

In this guide, we’ll show you how to list active screen sessions and how to reattach to a running session.



🔍 1. List Active screen Sessions​

To list all currently active screen sessions on the server, run the following command:
Bash:
screen -ls

You should see output similar to this:
Bash:
There is a screen on:
        12845.my_script     (Detached)
1 Socket in /run/screen/S-root.

In this output, 12845.my_script is the session name. The session ID is the number at the beginning: 12845.

jetto-screen-connect-1.webp




🔄 2. Reattach to a screen Session​

If a screen session is running in the background (detached), you can reattach to it using the command:
Bash:
screen -r -d 12845

Explanation:
  • -r: Reattach to the session
  • -d: Detach any other client that may be connected to this session

This command lets you resume a previously detached screen session and continue your tasks without starting over.
 
Thread owner
The screen allows you to manage processes running on the server without interrupting them. It is particularly useful for those performing lengthy installation or upgrade processes. This way, even if your connection drops, your process remains unaffected, and you can reconnect to the session.
 
Back
Top