LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Poweroff as user (http://www.linuxquestions.org/questions/slackware-14/poweroff-as-user-350891/)

Murdock1979 08-07-2005 02:58 PM

Poweroff as user
 
Quick Question:

How do I use the poweroff command in user mode (not su)?

thanks!
Mords

killerbob 08-07-2005 03:08 PM

You'd have to sudo it if you aren't su. It requires kernel permission levels that users simply don't have.

That said, I just push the power button on my computer. On both my laptop and my desktop, the kernel intercepts that button push and shuts down properly. I have no reason to suspect that it wouldn't work for you, either.

gbonvehi 08-07-2005 03:23 PM

The best way to give the users power like that would be to give them permissions to execute shutdown using sudo.
Use visudo to edit the rules file, you should put a line like:
Code:

youruser yourmachinename= NOPASSWD: /sbin/shutdown -h now
or
Code:

%users  yourmachinename= NOPASSWD: /sbin/shutdown -h now
to give all the users in users group access to it.

The the users would use: sudo /sbin/shutdown -h now

killerbob, unfortunatly, not all the machines behave like that :/

Nylex 08-07-2005 03:40 PM

Murdock, hope you don't mind me posting this question on your thread!

How do you use visudo? I can't seem to change the file and uncomment the line I need (same one as Murdock tbh).

gbonvehi 08-07-2005 03:49 PM

Visudo is actually vi, so you've to learn how to use vi.
Basically when you enter your are in "read-mode".
Try moving with the arrows, if you can't, use h,j,k,l to move the cursor.
Place at the character you want to remove (the #) and press x to delete the character.
If you need to input some text, press the i key, type what you want and go back to read mode using ESC key.
To save press
Code:

:wq
:w will write the file, :q will quit, and if you need to quit without saving, use, :q!

Edit: Here's a quick intro manual, http://www.macdevcenter.com/pub/a/ma.../vi_intro.html
If you want to go deeper be sure to have installed vim. Copy the file /usr/share/vim/vim63/vimrc_example.vim to ~/.vimrc
and run the program, vimtutor

Nylex 08-07-2005 03:53 PM

Thanks! Edit: God I hate vi ;).

XavierP 08-07-2005 04:04 PM

Alternatively, change the permissions on /sbin/shutdown /sbin/halt and /sbin/reboot to enable users to issue the commands.

Xian 08-07-2005 07:37 PM

Quote:

Originally posted by Nylex
Thanks! Edit: God I hate vi ;).
Heh. If you really hate it that much then just change the symlink in /usr/bin/vi from elvis to something like pico. Then when you visudo you won't need an aspirin.

EDIT: Seems like this entry would work as well.

username ALL = /sbin/shutdown

Nille_kungen 08-08-2005 02:29 AM

I only type 'halt' as user.
But i can't remember if i had to change some permissions (maybe group).

Nylex 08-08-2005 02:59 AM

It doesn't seem to work. I uncommented the line starting with "%users", but I still can't shutdown as a normal user :/.

shotwellj 08-08-2005 03:04 AM

Are you in the users group? Are you typing 'sudo /sbin/shutdown -h now'?


Jacob

Nylex 08-08-2005 03:06 AM

OH, I didn't realise you had to type "sudo" as well. Does anyone know how to get Xfce to work with this?

gbonvehi 08-08-2005 03:36 AM

Add a entry on the menu with that command :)

shotwellj 08-08-2005 03:48 AM

To use the xfce shutdown button, you'll need to visudo and add

Code:

%users ALL=(root) NOPASSWD: /usr/libexec/xfsm-shutdown-helper
That should be enough.

Jacob

Nylex 08-08-2005 03:59 AM

Nice one, thanks. Quick question though: why is it that you have to use visudo to edit the sudoers file, instead of being able to edit the file directly, like you can with fstab for example?


All times are GMT -5. The time now is 09:00 PM.