LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Closed Thread
  Search this Thread
Old 08-07-2005, 02:58 PM   #1
Murdock1979
Member
 
Registered: Oct 2003
Distribution: Slackware Debian VectorLinux
Posts: 429
Blog Entries: 2

Rep: Reputation: 30
Poweroff as user


Quick Question:

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

thanks!
Mords
 
Old 08-07-2005, 03:08 PM   #2
killerbob
Member
 
Registered: Oct 2004
Location: Ottawa, ON
Distribution: Slackware
Posts: 662

Rep: Reputation: 31
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.
 
Old 08-07-2005, 03:23 PM   #3
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
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 :/
 
Old 08-07-2005, 03:40 PM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
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).
 
Old 08-07-2005, 03:49 PM   #5
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
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

Last edited by gbonvehi; 08-07-2005 at 03:52 PM.
 
Old 08-07-2005, 03:53 PM   #6
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Thanks! Edit: God I hate vi .
 
Old 08-07-2005, 04:04 PM   #7
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Alternatively, change the permissions on /sbin/shutdown /sbin/halt and /sbin/reboot to enable users to issue the commands.
 
Old 08-07-2005, 07:37 PM   #8
Xian
Member
 
Registered: Feb 2004
Location: 33.31N -111.97W
Distribution: SuSE
Posts: 919

Rep: Reputation: 32
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

Last edited by Xian; 08-07-2005 at 07:49 PM.
 
Old 08-08-2005, 02:29 AM   #9
Nille_kungen
Member
 
Registered: Jul 2005
Distribution: Slackware64-current
Posts: 587

Rep: Reputation: 201Reputation: 201Reputation: 201
I only type 'halt' as user.
But i can't remember if i had to change some permissions (maybe group).
 
Old 08-08-2005, 02:59 AM   #10
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
It doesn't seem to work. I uncommented the line starting with "%users", but I still can't shutdown as a normal user :/.
 
Old 08-08-2005, 03:04 AM   #11
shotwellj
Member
 
Registered: Jul 2005
Location: Tempe, AZ
Distribution: Slackware
Posts: 66

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


Jacob
 
Old 08-08-2005, 03:06 AM   #12
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
OH, I didn't realise you had to type "sudo" as well. Does anyone know how to get Xfce to work with this?
 
Old 08-08-2005, 03:36 AM   #13
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
Add a entry on the menu with that command
 
Old 08-08-2005, 03:48 AM   #14
shotwellj
Member
 
Registered: Jul 2005
Location: Tempe, AZ
Distribution: Slackware
Posts: 66

Rep: Reputation: 15
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

Last edited by shotwellj; 08-08-2005 at 03:49 AM.
 
Old 08-08-2005, 03:59 AM   #15
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
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?
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
poweroff and shutdown with own user jaakkop Linux - General 6 12-29-2005 10:07 PM
how to poweroff ?? perdesiz Linux - Laptop and Netbook 5 12-29-2004 03:31 AM
poweroff with own user jaakkop Linux - General 2 12-28-2004 07:07 AM
enabling poweroff/reboot for user YBA^[x] Slackware 11 12-13-2004 02:04 AM
giving a user poweroff permission Goatdemon Slackware 7 07-19-2003 06:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration