I've launched into X using startx
, but now can't shutdown my pi, as I have no mouse, and I can't seem to access anything with the keyboard alone. What can I do?

- 4,089
- 8
- 31
- 46
-
Which OS do you have? – finnw Jun 21 '12 at 22:49
-
2@finnw The recommended Debian – Tom Medley Jun 22 '12 at 08:52
-
Try making a button adapting this tutorial http://www.repairhub.co.uk/content/resources/raspberry-pi-battery-backup – AwesomeUser Apr 22 '14 at 21:32
-
Have you tried unplugging it? – Aloha Dec 26 '16 at 02:49
5 Answers
Try pressing Ctrl+Alt+F1.
This will switch you to a different tty. After logging in on this you can run commands as normal
Any F key under 6 will do.

- 1,774
- 1
- 19
- 33

- 22,538
- 11
- 90
- 139
-
1This switched out to the console running X, I could then terminate X with
ctrl-c
and shutdown the machine. – Tom Medley Jun 20 '12 at 09:41 -
-
-
-
I'd be surprised if the system key or alt didn't work, but I haven't tried this. – jfa Jul 10 '15 at 14:41
Why not stop it with sudo /etc/init.d/lightdm stop

- 71
- 1
- 1
-
I doubt that that would be possible, unless there was a terminal window open, and currently focused when the mouse was removed. – hifkanotiks Sep 17 '12 at 18:19
-
If there is no window manager, decorator, etc. it means that
startx
didn't launchlightdm
. Thenlightdm
status is not set asstarted/running
and thus it can't be stopped withsudo /etc/init.d/lightdm stop
– Avio Sep 27 '12 at 20:51
Pressing Ctrl+Esc brings up the 'start' menu (for want of a better word) and then you can use the arrow keys to select 'logout'.
Which is the same as Windows - if you've not got a Windows key then Ctrl+Esc does the same thing (OK, a bit off topic but thought I'd make sure everyone understood I wasn't just thinking it was Windows and that it also works on the default Pi desktop).
-
However, this is dependant on the display manager, whereas my solution will work in any X session. – Jivings Sep 07 '12 at 14:09
Try Ctrl+Alt+Backspace.
This will kill the running X server.

- 22,538
- 11
- 90
- 139

- 15,530
- 14
- 67
- 113
-
4
-
-
No harm done. It's still useful to know. Some Window Managers re-enable it. – Jivings Jun 20 '12 at 08:38
-
@Jivings If I remember correctly, raspi-config actually allows to enable it. – Klaus-Dieter Warzecha Feb 07 '14 at 20:36
If sudo /etc/init.d/lightdm stop
works, then make bash script in /bin
:
$ cd /bin
$ sudo nano stopx
In the new file insert the following code:
#!/bin/bash
sudo /etc/init.d/lightdm stop
save and exit nano, i.e. Ctrl+x and then Enter
Make the file executable:
$ chmod +x stopx
Finally one may use stopx
as opposite of startx
!