I recently found out that reboot
works just as well as sudo reboot
, from what I can tell. However, in a lot of instances, I see people saying to sudo reboot
. Why is this? Are they the same, and just personal preference? Or are they different? Does sudo reboot
do more than reboot
?
On Ubuntu 14.10 and older,
sudo
is required.The introduction of Systemd in 15.04 changed the way Ubuntu handles
shutdown
andreboot
:When a single user is logged in,
sudo
isn't necessary. When more than one user is logged in thensudo
is required.Applications can inhibit
shutdown
andreboot
. You override these inhibitions withsudo
.A single user logged in via
ssh
still requiressudo
.On my 14.04 machine, when I (as a normal user) type
reboot
, I getThat is the difference.
As Terrance pointed out in the comments, it works differently on later systems than mine. So you are probably seeing old writeups and/or users (like me) who have been habituated to typing
sudo reboot
!sudo reboot
is used in tutorials / how-tos for compatibility reasonsWhile
reboot
might worksystemd
andsudo reboot
will "always"* work, regardless of* Well, it will certainly try - short of there being some kernel processes that are blocking/misbehaving it should work.
For myself many times if I type
reboot
it won't let me due to inhibitors from Chrome when watching YouTube and other opened tabs. So I'm forced to usesudo reboot
--a bigger hammer.This in Ubuntu 16.04
Thanks for the discussion, I'm glad to understand this now!
As Terrance mentioned, in version 15.04, they switched from Upstart to Systemd for the commands. This change means that
reboot
no longer requires root privileges.As for why the *nix community instructs to
sudo reboot
, there are a few potential reasons:sudo reboot
to reboot, they continue to do it despite the fact it is not neededNon-updated users - The people instructing to
sudo reboot
are on versions of Ubuntu lower than 15.04, or other distros that use Upstart for commands.Compatibility - This is what seems the most plausible to me: people are instructing to
sudo reboot
because it is guaranteed to reboot across all *nix systems, no matter what.Additional note: from user535733's answer: