Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Suppose I boot a Linux machine without GUI. When it displays a tty login prompt, can I shutdown the machine with a keyboard sequence?

Of course I could type in my username and password and then sudo shutdown -h now; however, is it possible to shut it down before the login using a keyboard shortcut?

share|improve this question
add comment

3 Answers

up vote 7 down vote accepted

I've done this before with a user named "s" and no password.

IIRC you set the user's shell to /sbin/shutdown. Prolly need to add it to /etc/shells.

share|improve this answer
add comment

On most Linux systems, the Ctrl+Alt+Del key sequence action is configured in either /etc/inittab or /etc/init/control-alt-delete.conf.

Usually, this will reboot the system, but you could modify the command to halt the system instead.

In /etc/inittab:

ca::ctrlaltdel:/sbin/shutdown -t3 -h now

Or /etc/init/control-alt-delete.conf:

start on control-alt-delete    
exec /sbin/shutdown -h now "Control-Alt-Delete pressed"
share|improve this answer
    
Can I also use another key sequence for this? (I don't want to overwrite the reboot thing) –  student Aug 9 '12 at 7:27
add comment

Here's a nice little trick that kind of surprised me (life saver if you freeze a remote system with no iLO (or KVM). The Magic SysRq key. If it is active on your system, I believe hitting ALT + SysRq + o should turn off your system. This is a hard shutdown (if I recall correctly, don't want to test it right now!) so you can press: ALT + SysRq + e (nicely kill all processes) ALT + SysRq + i Kill everything else) ALT + SysRq + s sync all file systems, ALT + SysRq + u to remount partitions as read only, then do the b or o combination (reboot or shutdown)

Anyway, I don't think this is the best way to halt your system, the other answers may be more suitable, but the above should help you out if your stuck!

share|improve this answer
1  
Although this works, it's a little bit like stopping your car by driving it into a pile of hay. Effective, and your car will probably be okay afterward. –  bahamat Aug 9 '12 at 0:58
    
I 100% agree with you, I tried to make that clear in my answer. If you do the key combination in the right way it is a little bit better, but yes, this is a shiny red button that does what it says and not much else. –  Rqomey Aug 9 '12 at 6:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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