Ubuntu: Why do CLI and GUI methods for shutting down have different security measures?


CLI option for shutting down the system is

sudo shutdown -h now  

This requires the user to give the administrator password, whereas shutting down via GUI doesn't require any password. Why does GUI method not require any password? Does it remember that we used the password to login? In that case why does it ask for a password in the terminal?

This is not a duplicate because I think there is no question regarding the password while shutting down the system.


The two situations are not really the same.

When you use shutdown from the command line you will restart or power off whatever computer you are logged into from that terminal. It could be your laptop or it could be a remote server. All logged in users will be affected so superuser privileges are required.

When you use the shutdown menu from the menubar, the computer will shutdown only if no other users are logged in. If other users are logged in, the shutdown option will in fact just log you out. Superuser privileges are not required since you can't affect other users.


I think the reason for this difference is mainly historical; command line tools assume a multi-user server environment with remote sessions, whereas graphical tools tend to cater more to local single-user desktop systems. If you are sharing a system with dozens of other users, for example in a corporate or collegiate environment in the 1980s, it makes sense to limit who can run shutdown, to avoid disruptions. But if you are sitting in front of your PC and you're the only one using it, it's kind of silly to prompt you for a password to shut down, since you could disconnect the power cable to achieve nearly the same thing.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »