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. Withscreen, 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 activescreen 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.🔄 2. Reattach to a screen Session
If ascreen 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.