81

I'm running QEMU on Linux without GUI.

After running starting my custom kernel with QEMU, I can't kill and return to host by pressing Ctrl+C.

Is there any way to get back to host OS?

6 Answers 6

149

Ctrl-A x

For -nographic just enter:

Ctrl-A x

which means

  1. first press Ctrl + A (A is just key a, not the alt key),
  2. then release the keys,
  3. afterwards press X (lowercase x; no Shift, case matters).

Alternatively:

Tested in Ubuntu 17.10, QEMU 2.10.1.

7
  • 1
    @vharron yes, my amazing explanation skills have finally been surpassed Commented Sep 25, 2019 at 21:19
  • 1
    qemu.org/docs/master/system/mux-chardev.html Commented Sep 28, 2023 at 7:20
  • 1
    @raddevus what's your host OS / QEMU version? Where I tested (Ubuntu 17.10, QEMU 2.10.1) and many other QEMU / Ubuntu versions it was Ctrl + A without shift for sure. Maybe it's a QEMU version / OS difference. Also in docs: qemu.org/docs/master/system/mux-chardev.html Commented May 19 at 20:31
  • 1
    @CiroSantilliOurBigBook.com Oh, interesting. I'm running Ubuntu 22.04.4 LTS and QEMU emulator version 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.19). Ok, i just tried it again with lowercase a and it works. I must've fat-fingered a couple of times. Sorry about the noise. I feel a bit dumb.
    – raddevus
    Commented May 19 at 20:34
  • 1
    @raddevus no problem, thanks for double checking! Commented May 20 at 7:39
15

To close a QEMU process in your shell:

ctrl+a, then x

1
9

Press Cntl-Alt-2 and then use the close button on the menu.

enter image description here

You can find more useful shortcuts here

1
  • 2
    I found the Ctrl part unnecessary. Alt-2 does the job.
    – Jet Blue
    Commented Sep 16, 2020 at 23:03
3

Ok, found a solution.

  1. Opened new terminal session: ctrl+alt+f2
  2. Used ps to find PID of previous tty: ps -fu
  3. Killed previous tty: kill -HUP PID
2
  • 6
    This is a really inferior solution to the most upvoted answer here. I will not downvote the answer, since it was entered before the better solutions.
    – EFraim
    Commented Aug 21, 2018 at 8:05
  • Not necessarily inferior, it still caters to situations where the CtrlA,X way doesn't work, eg when qemu gets stuck trying to bring up an OS. It's just an alternate answer.
    – Mendhak
    Commented Oct 15, 2023 at 11:21
2

This is just in addition to other answers, where ctrl-a x works but you've aliased over it. If you're like me, you're using tmux with ctrl-b replaced with ctrl-a, which is why you can't use ctrl-a x. A simple solution to this is to use tmux's send-keys utility to send ctrl-a x to qemu.

In a running tmux window, press ctrl-a : to bring up the tmux prompt, then type send-keys C-a x Enter and qemu will quit.

0

i tried

Ctrl + Alt + Q

That worked for me, even if most of the documentation I see only says to use

Ctrl + Q

1
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented May 23 at 18:19

You must log in to answer this question.

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