950

How can I shut down or reboot Ubuntu using terminal commands?

Byte Commander
  • 105,631
  • 46
  • 284
  • 425
Raja G
  • 100,643
  • 105
  • 254
  • 328
  • Related (but not a duplicate): [Shutting down the system using a virtual console](https://askubuntu.com/questions/872462/shutting-down-the-system-using-a-virtual-console) – Eliah Kagan Oct 16 '17 at 09:12

5 Answers5

1183

For shutdown:

sudo poweroff

For restart:

sudo reboot

Appendix: If your keyboard is "locked up", so you can't enter a command like "reboot" which would run from "su" anyway, use the keyboard: hold down Alt + PrintScreen/SysRq, buttons and type "REISUB". It doesn't have to be capital letters. It will restart your computer gently. http://blog.kember.net/articles/reisub-the-gentle-linux-restart/

FedKad
  • 9,212
  • 7
  • 40
  • 79
Saeed Zarinfam
  • 17,232
  • 6
  • 35
  • 41
  • 17
    `sudo` might not be needed, actually. – Nicolas Raoul Oct 20 '16 at 09:28
  • 3
    On Armbian, just `reboot` is not found. instead, `/sbin/reboot` works. – Mark Jeronimus Dec 19 '16 at 14:28
  • 1
    @MarkJeronimus It depends on your `PATH` variable, and your `SECURE_PATH` in the `/etc/sudoers` file. – Will Mar 12 '17 at 10:25
  • 8
    what about `shutdown now` and `shutdown -r now`? – Post Self Jan 08 '18 at 15:55
  • 1
    @NicolasRaoul nopes, for me i see this without `sudo`. `Failed to set wall message, ignoring: Interactive authentication required. Failed to reboot system via logind: Interactive authentication required. Failed to open /dev/initctl: Permission denied Failed to talk to init daemon.` – Paramvir Singh Karwal Jul 15 '19 at 17:30
  • On both [there is no need for `sudo`](https://askubuntu.com/a/787274/349837). [`shutdown`](https://manpages.ubuntu.com/manpages/bionic/en/man8/shutdown.8.html) will give you 1 minute. REI (from REISUB) is now disabled by default. – Pablo Bianchi Oct 14 '19 at 03:37
242

Open your terminal with CTRL+ALT+T and do these following commands

To shutdown the system:

sudo shutdown -h now 

To restart:

sudo reboot

& one more command for restart:

sudo shutdown -r now

Another way as one of the user mentioned.

For shutdown:

sudo halt

or:

sudo init 0 

For restart:

sudo init 6

You can get more info on the shutdown command by using one of the following:

  • shutdown --help
  • man shutdown
Wilf
  • 29,694
  • 16
  • 106
  • 164
Raja G
  • 100,643
  • 105
  • 254
  • 328
102

Hate passwords (sudo) and love one-liners?

For Ubuntu 15.04 and later

This is due to Ubuntu's shift in using systemd instead of Upstart

systemctl poweroff
systemctl reboot
systemctl suspend
systemctl hibernate
systemctl hybrid-sleep

Since hibernate is normally disabled by default in Ubuntu systems, you can enable this by checking this answer.

For Ubuntu 14.10 or earlier

Shutdown:

/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop

Restart:

/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart

Other commands you may like:

Suspend:

/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend

Hibernate: (if enabled on your system)

/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
Majal
  • 7,613
  • 4
  • 28
  • 43
44

On 16.04 no need of sudo

To shutdown/poweroff:

poweroff

To reboot:

reboot
Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
Severus Tux
  • 9,736
  • 9
  • 58
  • 97
  • 3
    `Failed to set wall message, ignoring: Interactive authentication required.` from ssh – kyb Sep 06 '18 at 20:11
19

Use

sudo shutdown -h (time) (message)

This will shutdown your computer and halt it. That is what the -h is for. Then, in the time area you can choose the shutdown delay (in minutes) and if you want you can send a broadcast message in the message area (like goodbye, or I'm shutting the thing down :P).

To restart the computer, type

sudo shutdown -r (time) (message)

Now, instead of shutting it down and halting it, you will restart your computer once it's shutdown. :)

Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
Jatttt
  • 2,287
  • 12
  • 31
  • 43
  • 1
    What do mean by, "This will shutdown your computer and halt it. That is what the -h"? What is the difference if we only use "shutdown" or "poweroff" command? What is so special about "halt"!? – Pranav May 25 '20 at 16:50