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?

link|improve this question

feedback

5 Answers

up vote 11 down vote accepted

There's a few ways:

sudo reboot
sudo init 6
sudo shutdown -r now
link|improve this answer
1  
Be careful with init. If the inittab has been changed, init 6 may be mapped to some other runlevel. I've seen a number of places that had the default runlevel after reboot set to single-user mode. – Satanicpuppy Dec 9 '09 at 19:24
feedback

sudo /sbin/reboot will get the job done every time.

link|improve this answer
1  
+1 for explicitly using the absolute path – Adam Rosenfield Dec 10 '09 at 1:08
feedback

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

link|improve this answer
What is the advantage of this over sudo reboot? – Daryl Spitzer Dec 11 '09 at 13:40
1  
It will notify your session manager that you're about to reboot, and f.e. save your session status (apps opened). I'm not sure whether reboot or shutdown does that. Also, as I wrote in the answer, you don't need sudo or su (you need to be allowed to do that by session manager, but this is usually true in most desktop distros). – liori Dec 11 '09 at 15:03
feedback

I found this page on computerhope.com:

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

link|improve this answer
halt & poweroff actually turn the machine off completely, shutdown will only reboot the machine with the correct switches provided. – John T Dec 9 '09 at 19:04
feedback

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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