Reboot using command line

Since I’ve been manually updating using apt update, upgrade I also manually reboot using this command
sudo init 6

Once I forgot sudo and it worked. I tested this using vanilla Ubuntu 14.04 and found sudo was mandatory

Is having init 6 function without sudo normal or an oversight?

1 Like

Interesting find and it goes deeper. Same with:

sudo reboot

I first tried reboot without sudo on ssh to a new Ubuntu Server 16.04 and it didn't work. So I didn't expect U-M 16.04 to be different but it sure is!

EDIT: In fact, init 6 doesn't work on Ubuntu Server 16.04 either.

EDIT2: It's the ssh session changing things. On a local console, Ubuntu Server reboots without sudo, too! I ssh'd back to my U-M box and it also didn't work that way. So it is the Ubuntu system.

Checking vanilla Ubuntu 16.04 in a virtual environment

fresh install
first boot no update - upgrade
init 6 reboots - no sudo required
performed updat upgrade
created standard user
logout and login as standard user
init 6 reboots - no sudo required
shutdown also works

For my single user system this is not a concern, however this is certainly wrong!

Related thread.

@pfeiffep, I tried a standard user and, as expected, can’t init 6 or reboot or shutdown -rF now with another user logged in. So partly right.

But it tells you you how to override systemctl with -i so a standard user can override any other logged in user. Not good.

@ouroumov Yeah, Messy messy messy.

I don’t understand partly right I believe you and I are comparing server to desktop
My case is a single user desktop & you stated "Ubuntu Server 16.04"

I found no difference in behavior regarding not requiring sudo between UM and Ubuntu [both 16.04]

My test case strongly indicates these symptoms reside in Ubuntu core

Sorry, my last tests were on desktop.

But I’m finding no differences with server so Ubuntu core is definitely indicated.

As for ssh, I have everything keyed for auto backups but I’m glad ssh does its own thing with these particular permissions.

1 Like

Direct copy from an answer to my question posed on Ask Ubuntu ... this sounds technically correct, but I question the wisdom

It is a design feature that since 16.04 you do no longer need root
privileges to shut down or reboot the system through any method. Instead
the systemd and its systemctl tool accept those commands from regular users.

All related commands like shutdown, reboot, halt, poweroff are symbolic links ("symlinks") to /bin/systemctl and init is a symlink to /lib/systemd/systemd now by the way. You can verify this using the command file $(which COMMAND), replacing "COMMAND" with the one you want to check.

A standard desktop user is also able to execute these commands with sudo.
The good news is if another user is logged in the commands won't work without sudo.


I got thinking more on this and realize the shutdown dialog hasn't needed sudo or equivalent for a long time. I mean the dialog from the shutdown icon, Ctrl+Alt+Delete or power button.

However, I did run into this when testing. Bill is the main user and Will is a regular user not a sudoer.

will@bill-xps:~$ init 6
User bill is logged in on seat0.
Please retry operation after closing inhibitors and logging out other users.
Alternatively, ignore inhibitors and users with 'systemctl reboot -i'.
will@bill-xps:~$ systemctl reboot -i

Yes, it reboots after telling you what you need to do. At least you need -i. :smirk: