Jay Taylor's notes

back to listing index

How do you detach the 2nd screen from within another screen? - Unix & Linux Stack Exchange

[web search]
Original source (unix.stackexchange.com)
Tags: linux howto command-line screen unix.stackexchange.com
Clipped on: 2021-09-17

Stack Exchange Network

Stack Exchange network consists of 178 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
  1. Image (Asset 1/10) alt= 18
  2. +1418
  3. Tags
  4. Users
  5. Unanswered
  6. Find a Job
  7. Jobs
  8. Companies
    1. Teams
      Stack Overflow for Teams – Collaborate and share knowledge with a private group. Image (Asset 3/10) alt=
    2. Create free Team
  • Asked 12 years, 6 months ago
    Viewed 38k times
    130

    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 Mar 16 '09 at 22:12
    Image (Asset 5/10) alt=
    If you've customized screen's escape character to something other than Ctrl-A, then the key sequence will be quite different. :)
    – slacy
    Mar 16 '09 at 22:28
  • Yeah, you're on your own with that. <esc> a d may work; the man page is ambiguous, since it says that a sends the escape character, then clarifies that what it means by that is ctrl-A. So it's a crapshoot.
    – chaos
    Mar 16 '09 at 22:37
  • 4
    Thanks, there we go, that's exactly what I remembered too and when I told it to my co-worker who was having this problem, he said it didn't work. Of course, now I found out he was pressing ctrl-a, ctrl-a, d, instead of ctrl-a, a, d. Voted and closed.
    – Artem Russakovskii
    Mar 16 '09 at 23:32
  • 1
    @brandizzi: Have you tested this? Because I deeply suspect it is not the case, and that the sequence you would use is ctrl-t a d.
    – chaos
    Oct 24 '13 at 15:19
  • 1
    @chaos have you tested this? I tried it right now and, yes, C-t t d detaches the screen inside a screen. Can you try it? Just add escape ^Tt to your ~/.screenrc.
    – brandizzi
    Oct 24 '13 at 16:47
  • -1

    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 Jul 14 '18 at 11:35
    Image (Asset 6/10) alt=

    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 Jul 7 '18 at 7:02
    Image (Asset 7/10) alt=

    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 Mar 21 '09 at 9:20
    Image (Asset 8/10) alt=
    This one has a better explanation
    – Sgnl
    Sep 21 '17 at 0:54

    Your Answer

    Thanks for contributing an answer to Unix & Linux Stack Exchange!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.

    Community wiki

    Not the answer you're looking for? Browse other questions tagged or ask your own question.

    Hot Network Questions

    more hot questions

    site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.9.17.40233

    Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group.

    This site is not affiliated with Linus Torvalds or The Open Group in any way.