485

I screen -r'd into a Django server that's running and I can't simply Ctrl + C and exit out of it.

Are there any alternative ways to get out of screen?

Currently, I manually close the tab on my local PC and ssh back in, but that's becoming tiresome.

0

6 Answers 6

800

Ctrl-a d or Ctrl-a Ctrl-d. See the screen manual # Detach.

8
  • 17
    yes, you generally do have a tl;dr moment with the man command. so when you have a tl;dr when doing man command_name, in this case man screen, you can generally access a shorter & pretty helpful version of the docs by --help option, command_name --help, this case screen --help.
    – Ashish
    Commented Sep 13, 2014 at 6:42
  • 3
    Here's a screen quick reference and a combined screen & tmux cheat sheet you may find handy.
    – Trutane
    Commented May 28, 2015 at 22:03
  • 4
    tmux --help gives me new tmux session, so I'm like: "Oh sh~ why"
    – St.Shadow
    Commented Feb 22, 2017 at 9:36
  • 5
    This does not work when using screen for connecting to a serial device.
    – josch
    Commented May 16, 2017 at 9:41
  • 5
    @josch You should be able to use ctrl-a + k or ctrl-a + ctrl-k to kill the current screen window. Ashish - The --help output only talks about command line options, it does not talk about the key bindings
    – Aner
    Commented Oct 6, 2017 at 19:21
179
  • Ctrl + A, Ctrl + \ - Exit screen and terminate all programs in this screen. It is helpful, for example, if you need to close a tty connection.

  • Ctrl + D, D or - Ctrl + A, Ctrl + D - "minimize" screen and screen -r to restore it.

8
  • 24
    I'm just clarifying for future readers. That's Ctrl-A followed by Ctrl-\, and Ctrl-A followed by Ctrl-D.
    – Julian
    Commented Nov 7, 2016 at 10:53
  • 2
    @Julian Detaching doesn't need Ctrl on both, just on ctrl+a. Works for me and if you do "ctrl+a" and then write ":help" you can see that it says that both ctrl+d and d works. Commented Dec 9, 2016 at 11:09
  • 1
    This should be the accepted answer, as it specifies both detaching and exiting.
    – emonigma
    Commented Mar 31, 2019 at 15:51
  • 1
    Ctrl-A -> Ctrl-D just exits from the session for me, leaving it running in the background. Ctrl-A -> \ will exit the session completely (on Oracle Linux 6). Commented Apr 1, 2019 at 16:03
  • 16
    To quit, it's Ctrl-a + \ , not Ctrl-a + Ctrl-\ ! The key bindings can be viewed by pressing: Ctrl-a + ?
    – feklee
    Commented Aug 9, 2019 at 9:49
112
  • Ctrl + A and then Ctrl+D. Doing this will detach you from the screen session which you can later resume by doing screen -r.

  • You can also do: Ctrl+A then type :. This will put you in screen command mode. Type the command detach to be detached from the running screen session.

2
  • 17
    It's simply "Ctrl-a" then "d"
    – Kostyantyn
    Commented May 20, 2013 at 11:40
  • 5
    @Kostyantyn It works (as the man pages says 'For your convenience') both with and without the Ctrl for the d - so "Ctrl-a" "Ctrl-d" works, and so does "Ctrl-a" "d". Take your pick.
    – Eborbob
    Commented Nov 21, 2016 at 15:44
79

Ctrl+a followed by k will "kill" the current screen session.

1
  • 9
    This is the correct answer to what the question is asking - "exit" screen NOT detach from it. Commented Jun 29, 2021 at 21:36
27

To terminate the screen session use

Ctrl + a followed by k

To detach session and restore later use

Ctrl + a followed by d
12

In addition to the previous answers, you can also do Ctrl + A, and then enter colon (:), and you will notice a little input box at the bottom left. Type 'quit' and Enter to leave the current screen session. Note that this will remove your screen session.

Ctrl + A and then K will only kill the current window in the current session, not the whole session. A screen session consists of windows, which can be created using subsequent Ctrl + A followed by C. These windows can be viewed in a list using Ctrl + A + ".

0

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