32

I am using screen /dev/tty-MyDevice to look at traffic on my serial port.

Pressing Ctrl+D does not cause the screen to terminate.

What I have to do in order to terminate it?

4 Answers 4

40

Use the screen quit command (normally ctrl-A \).

5
  • Ctrl+a Ctrl+-, yields a blank screen, Ctrl+a Ctrl+c yields a new screen, which Ctrl+D then is able to exit like all other screens I've encountered before this. Jan 25, 2015 at 0:55
  • 2
    Oops, markdown turned my "ctrl-\" into "ctrl-". Fixed.
    – aecolley
    Jan 25, 2015 at 1:04
  • 9
    It worked as Ctrl-a \ (that is Ctrl-a and then plain \ without ctrl). Strange that the link provided includes a Ctrl for the \.
    – niels
    Jul 4, 2016 at 13:06
  • This kind of works, but when connecting to a qemu serial pty this really kills it. That means I can't reconnect to it after that. With picocom, I can easily terminate the serial connection and reconnect later. Mar 7, 2018 at 15:04
  • 2
    CTRL-A k y Is better because it doesn't "quit" all of screen, just "kills" the current tab, which may or may not be the last tab. Aug 31, 2021 at 18:53
14

I run all my terminals inside a screen, and also sometimes use screen to connect to serial. If you screen /dev/ttyUSB0 inside screen, you'll just get a new window in your current session, not a new child screen.

In this case, press Ctrl-A k to kill only the current window rather than the entire screen process and your other windows with it. This is the kill window command.

10

Though aecolley's answer usually works then it did not work for me (could be because of Icelandic keyboard and Icelandic locale, but somehow doubt it). When in that situation then you can go to a different console and execute screen -ls and take note of the screen session number, the output should be something like this:

There is a screen on:
            6254.tty2.hostname           (Attached)
1 Socket in /var/run/screen/S-root

The screen session number her is then 6254.

Then you can issue the following command to close that screen session: screen -X -S 6254 quit

1

For me the issue turned out to be that I had inadvertently logged out of the Linux user account, and not the system I was controlling through the serial port. Once I logged back in, all of the normal screen commands such as Ctrl+a, k began working again.

Beyond that, if you can open a new screen window (Ctrl+a, c), another TTY (Ctrl+Alt+F1..12, or an SSH session, then you can run pkill screen or kill <PID of screen>.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .