You are not logged in.
Pages: 1
Is there a way I can use the reboot or poweroff commands without using sudo or root? Or is this a bad idea?
Last edited by Falcata (2008-09-04 00:19:30)
Offline
It's a very bad idea, but you could activate the setuid bit on /sbin/poweroff, /sbin/reboot, /sbin/halt, or /sbin/shutdown (type 'chmod u+s file'). What's the reason you want to do this? If it's just so you don't have to login as root every time, you can just use sudo. If you don't want to have to type sudo every time, I guess you could run visudo and give yourself permission to run, let's say, /sbin/shutdown without a password. Then create an alias in your .bashrc (or your shell's equivalent) such as 'alias shutdown="sudo shutdown"'.
Edit: I don't endorse using setuid to shutdown without root privileges. Do so at your own risk.
Last edited by dsr (2008-09-04 01:20:56)
Offline
Please read the manpage for shutdown. Everything is explained there (Under the Headline "Access Control").
Offline
Please read the manpage for shutdown. Everything is explained there (Under the Headline "Access Control").
+1
CTRL-ALT-DEL is a much safer method than setuid or passwordless sudo.
Offline
What about adding your user to the "power" group, as suggested in the wiki?
Microshaft delenda est
Offline
I used
chmod +s /sbin/halt
chmod +s /sbin/reboot
to allow me to Reboot and Shutdown from the Openbox Menu. Not sure if there is a better way but this worked like a CHAMP.:cool:
Offline
I would suggest using root to shutdown and reboot, but that's just my preference.
If (like me) you have a root terminal open on the desktop, it's just a simple case of:
Shutdown
shutdown -h now
Reboot
reboot
I use fluxbox and this works for me.
richs-lxh
Last edited by richs-lxh (2008-09-04 08:46:31)
Offline
How about this wiki-entry?
=> Allow_users_to_shutdown
"The mind can make a heaven out of hell or a hell out of heaven" -- John Milton
Offline
What about adding your user to the "power" group, as suggested in the wiki?
That won't help with 'reboot' or 'shutdown'. The group is only used by HAL which in turn is used by Xfce, for example.
1000
Offline
What's wrong with using sudo for shutting down ? The millisecond in which you gain root privileges before the system goes down is a security risk !?
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...
Offline
What's wrong with using sudo for shutting down ? The millisecond in which you gain root privileges before the system goes down is a security risk !?
Even though it seems nit-picky, I do see where this becomes a viable situation. For example, if I don't want to give my friend root privileges, but I want to let him use my laptop and, sequentially, shut it down when he's done.
Offline
moljac024 wrote:What's wrong with using sudo for shutting down ? The millisecond in which you gain root privileges before the system goes down is a security risk !?
Even though it seems nit-picky, I do see where this becomes a viable situation. For example, if I don't want to give my friend root privileges, but I want to let him use my laptop and, sequentially, shut it down when he's done.
Pressing the power button is not good enough for your friend eh ?
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...
Offline
What's wrong with using sudo for shutting down ? The millisecond in which you gain root privileges before the system goes down is a security risk !?
Or if you want shutdown in the menu sudo doesn't work right. At least I couldn't get it to.
Edit: And what is the SECURITY risk for allowing someone to shutdown the computer?
Last edited by monstermudder78 (2008-09-04 18:27:32)
Offline
to shut down via command line use "halt". That does a nice clean and normal shutdown.
to reboot, just use "reboot" as mentioned above.
Check me out on twitter!!! twitter.com/The_Ringmaster
Offline
moljac024 wrote:What's wrong with using sudo for shutting down ? The millisecond in which you gain root privileges before the system goes down is a security risk !?
Or if you want shutdown in the menu sudo doesn't work right. At least I couldn't get it to.
Edit: And what is the SECURITY risk for allowing someone to shutdown the computer?
Funny, shutdown via sudo works alright in the openbox menu for me....
EDIT: Oh, I think I see what you meant. Why wouldn't you use the NOPASSWD for shutdown ?
Last edited by moljac024 (2008-09-04 20:02:23)
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...
Offline
edit /etc/shutdown.allow and add your username.
I created off an on in /usr/sbin.
#!/bin/bash
shutdown -h now
#!/bin/bash
shutdown -r now
off shuts me down and on reboots. Simple eh?
Offline
monstermudder78 wrote:moljac024 wrote:What's wrong with using sudo for shutting down ? The millisecond in which you gain root privileges before the system goes down is a security risk !?
Or if you want shutdown in the menu sudo doesn't work right. At least I couldn't get it to.
Edit: And what is the SECURITY risk for allowing someone to shutdown the computer?
Funny, shutdown via sudo works alright in the openbox menu for me....
EDIT: Oh, I think I see what you meant. Why wouldn't you use the NOPASSWD for shutdown ?
Just so we are on the same page: I wanted an entry on my openbox menu for reboot and shutdown so I could right-click the desktop and select reboot or shutdown. When I set the menu command to "sudo shutdown" it worked as long as I had used sudo in a terminal in the last 5 minutes (or whatever the time limit is) but would just freeze if I hadn't used sudo recently. My fix was to chmod +s halt and reboot, allowing the halt and rebnoot command to be executed from the menu.
My question: What is the difference between 'chmod +s halt' and NOPASSWD for shutdown as you suggested? I am not familiar with NOPASSWD.
Offline
[threadjack]
Can anyone offer a good explanation of the difference between "poweroff" and "shutdown -h now"? What exactly is the "safely" part of bringing down the system and is there a real reason to use "shutdown -h now" instead of using "poweroff" (which is faster)?
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
My question: What is the difference between 'chmod +s halt' and NOPASSWD for shutdown as you suggested? I am not familiar with NOPASSWD.
NOPASSWD is specified when you configure sudo, so some commands will be executed without asking for your users password. This is probably why it wasn't working for your menu, the computer was waiting for a password but there wasn't a way to display that request or enter it in.
Offline
My question: What is the difference between 'chmod +s halt' and NOPASSWD for shutdown as you suggested? I am not familiar with NOPASSWD.
NOPASSWD is specified when you configure sudo, so some commands will be executed without asking for your users password. This is probably why it wasn't working for your menu, the computer was waiting for a password but there wasn't a way to display that request or enter it in.
Exaclty. So you could specify the NOPASSWD parameter for the shutdown command and sudo will just do it without asking for the password. You should have an example of how to use that in your sudoers file. If not, then
man sudo
Last edited by moljac024 (2008-09-04 23:09:01)
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...
Offline
My question: What is the difference between 'chmod +s halt' and NOPASSWD for shutdown as you suggested? I am not familiar with NOPASSWD.
NOPASSWD is specified when you configure sudo, so some commands will be executed without asking for your users password. This is probably why it wasn't working for your menu, the computer was waiting for a password but there wasn't a way to display that request or enter it in.
That makes sense, and is in line with what I figured was going on. With NOPASSWD which commands would be executed w/out asking for a password? How would this be more "secure" than using chmod +s on halt and reboot? It seems that both ways accomplish the same thing in the end, I am just trying to understand why one is better than the other.
mcmillan wrote:My question: What is the difference between 'chmod +s halt' and NOPASSWD for shutdown as you suggested? I am not familiar with NOPASSWD.
NOPASSWD is specified when you configure sudo, so some commands will be executed without asking for your users password. This is probably why it wasn't working for your menu, the computer was waiting for a password but there wasn't a way to display that request or enter it in.
Exaclty. So you could specify the NOPASSWD parameter for the shutdown command and sudo will just do it without asking for the password. You should have an example of how to use that in your sudoers file. If not, then
man sudo
Please excuse my ignorance, but how is this better than chmod +s, which allows my user to use it w/out sudo? It seems as though one lets ME use sudo w/out a password, the other lets ME use the command w/out sudo. What is the benefit to using sudo without a password, other than not having to physically type the password?
Last edited by monstermudder78 (2008-09-04 23:13:40)
Offline
chmod +s -> every users can shutdown your machine
NOPASSWD -> depend how you configure sudo
Offline
scarecrow wrote:What about adding your user to the "power" group, as suggested in the wiki?
That won't help with 'reboot' or 'shutdown'. The group is only used by HAL which in turn is used by Xfce, for example.
It would be a nice, clean solution though if there was, say a program that simply used the interface to put up a simple gtk shutdown menu... Adding yourself to a group rather than messing about with sudoers would be an improvement.
EDIT: I don't suppose there is a way to use the hal interfaces from the command line? Like gmount only for power settings?
Last edited by chochem (2008-09-05 00:17:31)
Offline
[threadjack]
Can anyone offer a good explanation of the difference between "poweroff" and "shutdown -h now"? What exactly is the "safely" part of bringing down the system and is there a real reason to use "shutdown -h now" instead of using "poweroff" (which is faster)?
Their command-line options differ, so you probably want to read the manpages, but I believe during normal operation (runlevel 3 or 5) the following is correct:
"shutdown -h now" is functionally the same as "poweroff" which is functionally the same as "halt -p" or just "halt"
"shutdown -r now" is functionally the same as "reboot" which is functionally the same as "halt -r"
Offline
Their command-line options differ, so you probably want to read the manpages, but I believe during normal operation (runlevel 3 or 5) the following is correct:
"shutdown -h now" is functionally the same as "poweroff" which is functionally the same as "halt -p" or just "halt"
"shutdown -r now" is functionally the same as "reboot" which is functionally the same as "halt -r"
Thanks. On my system though, "poweroff" is quite fast (seems to just kill the X server, then I see all the background processes being terminated in the console, then it powers off) whereas "shutdown -h now" takes a minute and doesn't seem to be doing anything. I was mostly curious to know if it's doing during that minute that "poweroff" doesn't do and if that matters.
Maybe it's more for multiuser systems to give others time to save their work etc (since replacing "now" with an integer delays the shutdown and sends the message to others).
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Pages: 1