How do I shut down or reboot from a terminal?
Solution 1
For shutdown:
sudo poweroff
For restart:
sudo reboot
Appendix: If your keyword is "lockup" 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/
Solution 2
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
Solution 3
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
Solution 4
On 16.04 no need of sudo
poweroff
To reboot:
reboot
Solution 5
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. :)
Related videos on Youtube
mx7
LinkedIn Profile: https://in.linkedin.com/in/raja-genupula-05205531 Endorse me If I helped you. Blog : http://thelinuxmen.blogspot.com/ Ubuntu - CentOS - Fedora - Windows - Severs - IIS - FTP - Security Thank you.
Updated on September 18, 2022Comments
-
mx7 almost 2 years
How can I shut down or reboot Ubuntu using terminal commands?
-
Admin over 6 yearsRelated (but not a duplicate): Shutting down the system using a virtual console
-
-
fromnaboo about 11 years@jai the target is to offer the op and everyone else alternative ways of doing what he has asked.
-
ubiquibacon about 10 yearsIt seems
shutdown -r now
is preferable toreboot
as the second can put you into maintenance mode -
NorthLattitude almost 9 yearsI always wondered how the GUI shutdown the system without needing sudo. I assume this is it.
-
Mark Jeronimus over 7 yearsOn Armbian, just
reboot
is not found. instead,/sbin/reboot
works. -
Franck Dernoncourt over 7 years
-
Will Dereham over 7 years@MarkJeronimus It depends on your
PATH
variable, and yourSECURE_PATH
in the/etc/sudoers
file. -
Post Self over 6 yearswhat about
shutdown now
andshutdown -r now
? -
Hee Jin about 6 yearsCan anyone explain why
sudo halt
might not perform shutdown in some cases, whereassudo halt -p
does? -
kyb almost 6 years
Failed to set wall message, ignoring: Interactive authentication required.
from ssh -
Hashim Aziz almost 6 yearsToday I found an advantage to
systemd
. -
Paramvir Singh Karwal almost 5 years@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.
-
Pablo Bianchi over 4 yearsOn both there is no need for
sudo
.shutdown
will give you 1 minute. REI (from REISUB) is now disabled by default. -
Pranav about 4 years@systemd And what is that?!
-
Pranav about 4 yearsWhat 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"!?