How do you detach the 2nd screen from within another screen?

I’ve accidentally attached to a 2nd GNU screen session from within an existing screen session and cannot detach or issue commands to the inner screen. I remember figuring out how to do that before but completely forgot and would like to keep it as reference.

One way is to detach the inner screen by doing screen -dr from shell, but what is the key combination to do that from within screen itself?

ctrl-a a d

Answered By: chaos

ctrl+a a will pass the escape sequence (ctrl+a) to the sub-screen.. So, ctrl+a a d will do ctrl+a d in the sub-screen (detaching it)

It works with any screen command, for example ctrl+a, a, c will create a window in the sub-screen

Answered By: dbr

In general, if you have a screen s3 within another screen s2 within another screen s1, you can execute a command ctrl-a d in the screen:

  • s1 by doing: ctrl-a d
  • s2 by doing: ctrl-a a d

  • s3 by doing: ctrl-a a a d

Answered By: watou

Well, there is a hack for this. Just remotely de-attach the required screen by following command

screen -r -d screen_name or screen -rd screen_name
Answered By: Rimjhim .
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.