10

I would like to do that using the command-line, because sometimes my computer freezes and I need to force a shutdown (I know it's not good to the hardware). And: What is the difference between Halt and Shutdown commands?

5

Using the commands shutdown and reboot respectively. To log off from a terminal you can press Ctrl-D or type exit.

  • 1
    or type exit instead of Ctrl+D ... or just execute shutdown/reboot via SSH ssh root@brokenbox reboot – Bananguin Jul 5 '12 at 21:58
10

If you can still access a text mode console, or if you can log in remotely:

  • You can use ps or other process listing tools and kill to try killing some processes. A few programs will save your work (at least to a recovery file) if they receive a kill -HUP or plain kill. They might not have time to do it if you go straight for rebooting.
  • Run sudo kill followed by a process ID to kill a process that's running as root or some other user who is not you.
  • Run reboot to reboot (e.g. sudo reboot if you use sudo to gain administrative access). Run halt to power the computer off. Both of these call shutdown with appropriate options.

If absolutely everything is hosed, but you have console access, you can use magic SysRq to at least flush all file changes to disk unmount filesystems cleanly. Press

  1. Alt+SysRq+E to send SIGTERM to all processes (optional).
  2. Alt+SysRq+S to synchronize (flush) filesystem changes to disk.
  3. Alt+SysRq+U to forcefully unmount (actually, remount read-only) all filesystems.
  4. Alt+SysRq+B to reboot.

(Note: you'll sometimes see “REISUB”, but the R and I steps are useless.)

  • 1
    Just to make it easy to remeber, its BUSIER backwards. – Spidey Jul 11 '12 at 21:53
2

If it is a frozen X session, hit ctrl+alt+f1 to get to a console. Log in and from there, execute /sbin/shutdown, /sbin/reboot or /sbin/shutdown -r now. Depending on permissions, you may need to prefix these commands with sudo or first su to become root.

You may also be able to kill the offending process. Run ps aux to list all processes and look for ones which are using a lot of CPU and/or memory (third and fourth columns). Use kill <pid>, where pid is the number in the second column of the ps output). If this doesn't kill the process, you may need to run kill -9 <pid> to forcefully kill it.

  • ctrl+alt+f1 may not work on all systems (some have the X session there), but ctrl+alt+f3 will on most, except for installation live systems maybe. – Jonas Schäfer Jul 12 '12 at 17:30
0

If your BIOS is setup in a way where you have to press the power-button more than X seconds to actually turn off the machine, press the power-button once. This will give the acpi-signal for shutdown/halt/poweroff.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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