LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   regular users using halt (https://www.linuxquestions.org/questions/debian-26/regular-users-using-halt-249558/)

TimmyP 10-31-2004 03:06 PM

regular users using halt
 
back a few months ago when i was running mandrake 9.1, any user on my computer was able to open a command prompt and issue the halt, reboot, and shutdown commands. after switching to debian, those commands are reserved for the su.

i tried copying "halt" and "reboot" to /usr/bin and changing the permissions (...it made since at the time) but i had no luck.

thanks for your help.

TimmyP

ToniT 10-31-2004 07:13 PM

Code:

chmod u+s /sbin/halt

McCloud 10-31-2004 07:39 PM

Install the SUDO package. With SUDO you can define which users/groups are allowed to run certain commands (you can specify the commands) with different (for example root) permissions. You can even specifiy whether they have to enter a password when they execute a certain command.

I had the problem that I had to switch to my root account to shutdown my pc. Now I can just type "sudo shutdown -h now" in my user account.

Do a Google search on 'sudo' to find more information.

Dead Parrot 10-31-2004 10:09 PM

Setting User ID for /sbin/halt, like ToniT suggests, allows you to shutdown your computer as normal user using the "halt" command (and you can reboot with Ctrl-Alt-Del). But just for the fun of it, here's how to use Sudo to achieve the same thing:

First, you'll probably want to use nano as your system's default text editor. Do "update-alternatives --config editor" and choose nano's number from the list. Then edit ~/.bash_profile and add these two lines:
Code:

EDITOR=nano
export EDITOR

And while you're editing ~/.bash_profile, you can also add some command aliases:
Code:

alias  halt="sudo /sbin/halt"
alias  reboot="sudo /sbin/reboot"

Then logout and login again so that the changes in ~/.bash_profile take effect.

Next, "su" to root, do "apt-get install sudo" to install the Sudo package, and then type "visudo". Now the /etc/sudoers file should open in nano. Type the following line to the bottom of that file (replace "username" with your username):
Code:

username  ALL = (ALL) NOPASSWD: /sbin/halt, /sbin/reboot
Then exit nano saving changes. After doing this you should be able to use the "halt" command as normal user to shutdown computer and the "reboot" command to reboot. :cool:

TimmyP 11-08-2004 03:06 AM

thank you for your help, i ended up going with the sudo method.

thanx again


TimmyP


All times are GMT -5. The time now is 01:32 AM.