If I've got Raspbian running with a keyboard but no monitor, how do I shut it down with that keyboard?
Solutions for shutting down from either the unlogged-in terminal or the desktop (or preferably both) would be appreciated.
If I've got Raspbian running with a keyboard but no monitor, how do I shut it down with that keyboard?
Solutions for shutting down from either the unlogged-in terminal or the desktop (or preferably both) would be appreciated.
From the terminal mode: press Ctrl-Alt-Del on the keyboard.
This is configured in /etc/inittab:
# What to do when CTRL-ALT-DEL is pressed. ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
From the desktop: it depends on what desktop software.
Sorry, I don't understand the instructions. What does the first bit mean for example? ca:12345? ca? Do you mean type a colon or is that just your indication of a separator? What does that do with no app running?
The ctrl-alt-del brings up the task manager and I can see that the text gets typed in at the bottom right, but disappears after a second or so. I can't type that stuff in _with_ a monitor.
Never mind. Got it. I got confused first trying your instructions at the terminal, then when that didn't work at the desktop. I must've mistyped the first time round. Thanks.
You do not need to do anything with those lines except verify that indeed they are there in /etc/inittab.
When you hit ctrl-alt-del the system will run /sbin/shutdown -t1 -a -r now
When you want to know how that works and what else you can do, type: man inittab
I'll add for the benefit of anybody as confused as I was:
edit /etc/innitab and find this line:
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
then change the -r to -h
then just do ctrl-alt-del in terminal mode (the change isn't effective until it's rebooted once). It now shuts down instead of rebooting.
I'm not sure what -a or -t1 does since that's not in man shutdown or shutdown --help.
-a means it will consult /etc/shutdown.allow if present, to see who is allowed to shutdown.
-t1 is related to timing during the shutdown.
You are right, when you want it to remain off after Ctrl-Alt-Del you can use -h instead of -r, else it will reboot. (normally I just pull the power when it wants to reboot, at least then you have done a clean shutdown)
Changes to /etc/inittab become effective immediately if you type init q (as root or using sudo)
Yes, I can just recycle the power for reboot, but it would be nice to have hotkeys for shutdown _and_ reboot. Google only seems to turn up people asking the same question but no solution:
one quick option would be to change the program run to a simple script that waits for another key-press & then calls the correct variant. I may experiment with this later if i get the time.
another option is the SysRq key which has various options if enabled correctly (google linux SysRq)
-- Bad men live that they may eat and drink, whereas good men eat and drink that they may live. -- Socrates
Sounds good. Grabbing the keyboard is the hard bit I guess.
Op Sun, 19 Oct 2014 09:22:56 +0000 (UTC) schreef Ed Davies:
info shutdown describes what -a and -t1 do.
-- Coos CHForth, 16 bit DOS applications http://home.hccnet.nl/j.j.haak/forth.html
to be honest i think the SYSRq key is what you want
it enables you to flush buffers, shut down or kill all processes, halt or reboot the system & it is built in at the kernel level.
-- dpkg has bugs? no way!
Another option is to have something that runs halt or shutdown when it sees one of the GPIO pins change state. I have an app which runs on the Pi and it using the GPIO pins anyway, without any keyboard or display. So I have the app monitor a spare i/o port* which has a 'HALT' button connected to it, and it fires off a configurable command, such as "(sync; sync; sync; poweroff)&" Of course, this only works if the app itself is working at the time.
*In my case this isn't directly one of the Pi's GPIO pins but an SPI expansion i/o port. However, you could do it with one of the Pi's GPIO pins and a suitable program.-- Andrew Gabriel [email address is not usable -- followup in the newsgroup]
If you have spare GPIO pins, you can wire buttons to it to do that and use a simple shell script to monitor/control. Shorting one of the I2C lines to 0v will reboot a halted Pi too.
Gordon
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.