Problem
Within an SSH session, I had Screen running. The terminal had froze. That Screen session still believes it’s attached after restarting Terminal. Perhaps it is. Maybe I’m not quite sure what that implies.
From a new SSH login, I’d like to join that Screen session. I don’t want to end that Screen session since there are significant things going on over there. 🙂
I believe I have the following alternatives (none of which I know how to solve):
Asked by T. Brian Jones
Solution #1
As Jose suggested, screen -d -r should enough. According to the man page, this is a combination of two instructions.
screen -d disconnects an already-running screen session, while screen -r reconnects it. You may force screen to detach it and then resume the session by typing screen -d -r.
I cite the man page if you use the capital -D -RR because it’s too fantastic to pass up.
Answered by Matt S.
Solution #2
Use screen -d -r or screen -D -RR instead.
Answered by Jose Luis Martin
Solution #3
Background: Whenever I looked for a solution to an issue with the same description, I always came across this answer. I’d want to offer a more practical solution. (For example, the other associated screen is a different size from the one in my terminal, and I can’t force it to resize.)
1. Use screen -x to reattach a session.
-x Attach to a screen session that hasn’t been disconnected yet without disconnecting it
2. This session’s list of displays: * PREFIX
PREFIX:default displays’s key binding is this. Identify the other display we wish to disconnect while performing it within the screen (e.g. smaller size). (When not selected, your current display is displayed in a brighter color/bolder font.)
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) rwx
Select the desired display with the arrows, then press d. If nothing happens, you attempted to detach your own display, but the screen refused to do so. If it was another, the entry will vanish after a second or two.
Press ENTER to quit the listing.
Optionally, reflow: PREFIX F to make the content match your screen (uppercase F)
Excerpt from the screen’s man page:
Answered by user10874456
Post is based on https://stackoverflow.com/questions/20807696/how-do-i-force-detach-screen-from-another-ssh-session