Force Detach Screen From Another SSH Session
Option 1: Using -d -r
screen -d -r
should do the trick.
This is a combination of two commands.
screen -d
detaches the already-running screen session, and screen -r
reattaches the existing session.
By running screen -d -r
, you force screen to detach it and then resume the session.
Option 2: List displays
Short answer
- Reattach without ejecting others:
screen -x
- Get list of displays:
^A *
, select the one to disconnect, press D
Explained answer
PREFIX
is usually ^A
= Ctrl + A .
Reattach a session:
screen -x
.-x
attach to a not detached screen session without detaching it.List displays of this session:
PREFIX *
.It is the default key binding for:
PREFIX :displays
. Performing it within the screen, identify the other display we want to disconnect (e.g. smaller size). (Your current display is displayed in brighter color/bold when not selected).term-type size user interface window Perms
---------- ------- ---------- ----------------- ---------- -----
screen 240x60 you@/dev/pts/2 nb 0(zsh) rwx
screen 78x40 you@/dev/pts/0 nb 0(zsh) rwxUsing arrows ↑ ↓ , select the targeted display, press D . If nothing happens, you tried to detach your own display and screen will not detach it. If it was another one, within a second or two, the entry will disappear.
Press Enter to quit the listing.