I wrote a bunch of shell script functions to switch between 3 different OSs I have on Raspberry Pi so that I could use Siri/homebridge to switch between them.

I was testing everything out while I was ssh'ed in and I watched things happen on the TV the RPi is connected to via HDMI.

Everything works great except when I use any of the "stop" functions to exit out of any of the 3 OSs to get back to the console. The OSs (either Kodi, emulationstation/retropie, or raspbian) all stop fine, but I'm not kicked out to the console. All I get is a black screen.

I discovered, after an inordinate amount of time to get the right google search terms, that I can type alt+F1 to be able to see the console on the TV.

My question is, what can I put in my shell script functions to do this programmatically? I.e. What's the command line equivalent of alt+F1?

  • Not sure that function keys are coded the same across all OS's, but this might help.
    – Seamus
    May 6, 2019 at 0:10

1 Answer 1


You are looking for the chvt utility.

$ sudo chvt 1

  • hmmm... It didn't work the first time I tried it. I had to run sudo chvt 2 first (which showed a login prompt on the screen). Then executing sudo chvt 1 returned me to the familiar console screen. I tried it a couple times. Is there anything I need to do before sudo chvt 1 to make it work? I suspect that this situation is caused by export DISPLAY=":0" which I need to do in order to start kodi via ssh...
    – hepcat72
    May 6, 2019 at 0:32
  • The VTs are a kernel thing. X11 isn't involved, the Xserver just occupies one of the VTs. You asked about Alt+F1, so that's the same as chvt 1 does.
    – Janka
    May 6, 2019 at 0:49
  • I guess the reason why it doesn't work is you are in VT1, but it's set to a weird mode. A VT switch will re-initialize it. What you could do is assign each of the systems a different VT and simply switch between them and the VT console.
    – Janka
    May 6, 2019 at 0:56
  • It must have to do with the way I’m killing kodi/emulationstation/raspbian. I’ll mark your answer and ask a separate question.
    – hepcat72
    May 6, 2019 at 1:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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