Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I turn on my machine and I log in to my account I can do whatever I want and even shutdown my machine or say reboot.

But if I open terminal and try to run the command reboot or shutdown then I need to have root access. Why is this so?

I can think of some reasons this kind of behavior like for you may find it desirable for ssh but I am not sure about it, or I can be totally missing some point.

share|improve this question
    
Check up on dbus and your graphical environtment (e.g. KDE or gnome). –  Hennes Sep 20 '12 at 17:08
    
I think you can do it on every gui, I just want to know why such design feature is there. –  Aman Deep Gautam Sep 20 '12 at 17:11
add comment

1 Answer

up vote 5 down vote accepted

Its a safety feature.

When using the GUI, you are (typically) sitting in front of the computer you are working on. However, when using a terminal, you might be physically on one machine and remotely using another. You might have many terminal windows open to many different machines. What if you accidentally type reboot in the wrong one? That action could range from an inconvenience to a complete disaster.

By using sudo it forces you to use a password. If you type in the wrong password it gives you an error and hopefully you realize that you are in the wrong terminal. This is why its good practice to have a different root password on every server.

share|improve this answer
    
I also thought the same but just wanted to make sure that I am not missing something..:) –  Aman Deep Gautam Sep 20 '12 at 17:28
1  
Ive seen more than a few Unix admins remove the computer name from their shell prompts because it took up to much space and later regret that decision. –  Keltari Sep 20 '12 at 17:33
    
Note that is not exactly a safety feature in the sense understood here. When Unix started, you only got consoles (no GUI). And only the root user had permission to shutdown/restart. It is still that way. The GUI bypasses using the +s bit in files. Although you can remove those in your menu using these commands: askubuntu.com/questions/53308/… –  Alexis Wilke Dec 27 '12 at 8:50
    
I just saw my CentOS VM claim "reboot" was not a command when I was su-ed as root. I typed sudo reboot there and it worked. When I directly SSH in as root, reboot works fine. It's weird. –  Steven Lu Jul 25 '13 at 5:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.