49

Because of my problem with mouse-clicks being ignored in Ubuntu, I want to restart from the command-line. (I have an open Terminal, and the keyboard is not ignored.)

How do I restart a computer running Linux (or more specifically Ubuntu) from the command-line?

7 Answers7

80

There's a few ways:

sudo reboot
sudo init 6
sudo shutdown -r now
9

If you've got freedesktop-compliant session manager, you can use DBus to invoke restart from inside the X session. The command goes:

dbus-send --system --dest=org.freedesktop.Hal --type=method_call \
    --print-reply /org/freedesktop/Hal/devices/computer \
    org.freedesktop.Hal.Device.SystemPowerManagement.Reboot int32:0

(this is probably more than necessary; works for me). I use this in a shell script. You don't need to run this from root, but you need to run it from inside an X session (f.e. in a terminal). You can find more on this topic at https://wiki.ubuntu.com/DebuggingGNOMEPowerManager

liori
  • 3,348
2

Occasionally, the usual (and preferred) reboot and shutdown commands don't work. I've seen this on a system with problems (which is why it needed rebooting).

You can trigger the "Magic SysRq" mechanism from the commandline:

echo b >/proc/sysrq-trigger

This is equivalent to alt-SysRq+b and will reboot the machine.

You may want to try "s" and "u" first to sync discs and unmount filesystems respectively.

Draemon
  • 778
1

I found this page on computerhope.com:

The command is reboot. There is also halt, poweroff & shutdown.

0

Immediately reboots the system

echo b > /proc/sysrq-trigger

0

If you are working in Virtual Environment It will put hard disk on Standby Mode: sudo /sbin/shutdown -h now.

0

nothing wrong with any of the above, but you can also install gnome-do and enable the session management plugin, which lets you easily shutdown,reboot,suspend from gnome-do

user23307
  • 7,127