LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-03-2005, 11:24 AM   #1
amwink
Member
 
Registered: Mar 2005
Location: Connecticut/USA
Distribution: Ubuntu 9.04
Posts: 68

Rep: Reputation: 15
Allowing users to shutdown - Slack 10.1


Is there a way to allow ordinary users (ie: non-root) to shutdown and poweroff/restart the system?

Tks.
 
Old 03-03-2005, 11:50 AM   #2
oneandoneis2
Senior Member
 
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460

Rep: Reputation: 48
Yes: Sudo

However, I confess to cheating with this one: I have XDM as my GUI login screen. And thanks to wish and tcl/tk, I have some buttons on the XDM screen that initiate shutdown or reboot. And since XDM is run as root, that takes care of the whole thing very nicely.
 
Old 03-03-2005, 11:52 AM   #3
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,775

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
For my part, I edited vi /etc/sudoers and added :
keefaz master = NOPASSWD: /sbin/shutdown -h now, /sbin/poweroff, /sbin/reboot

(master is my hostname, to know your hostname, type hostname in a terminal)

So to shutdown, I use :
sudo /sbin/poweroff
 
Old 03-03-2005, 12:45 PM   #4
amwink
Member
 
Registered: Mar 2005
Location: Connecticut/USA
Distribution: Ubuntu 9.04
Posts: 68

Original Poster
Rep: Reputation: 15
My system starts in the runlevel 3 by default, so I can't use the XDM tweak. Thanks anyway!

I edited the /etc/sudoers, as keefaz suggested, but no success yet. It asks me for a password, but the root's appears not to work even and after the 3 attempts.

The line I added to /etc/sudoers is bellow:

Code:
ander schwarz = NOPASSWD:/sbin/shutdown -h now
What am I doing wrong?

Ander
 
Old 03-03-2005, 12:49 PM   #5
amwink
Member
 
Registered: Mar 2005
Location: Connecticut/USA
Distribution: Ubuntu 9.04
Posts: 68

Original Poster
Rep: Reputation: 15
Just explaining: following the KISS philosophy, I decided to put only the shutdown command. After getting it working, I'll put the poweroff and reboot.

Obviously I'm not trying to run poweroff and reboot yet. Just the shutdown, which isn't working.

Thanks
 
Old 03-03-2005, 01:28 PM   #6
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
You're aparently doing fine, just a doubt, is ander your username and schwarz your hostname? Double check that.
 
Old 03-03-2005, 01:33 PM   #7
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,775

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
[edit]
I just did some checking, the syntax above is correct, no need to add
ander ALL=(ALL) ALL

Last edited by keefaz; 03-03-2005 at 01:46 PM.
 
Old 03-03-2005, 01:43 PM   #8
cavalier
Member
 
Registered: Feb 2005
Location: Denver, CO
Distribution: Slack 12, tweaked just so (though I'm also a fan of Ubuntu)
Posts: 198
Blog Entries: 1

Rep: Reputation: 30
FWIW, I have the following line in my sudoers file:

Code:
jas     ALL = NOPASSWD: /sbin/halt, /sbin/reboot, /sbin/mount, /sbin/umount
The only real difference I see is that I didn't limit myself to any particular host (used ALL instead) and put a space between the colon after NOPASSWD and the first forwad slash.

Also, I went with commands without parameters that let me do everything I want to do.
 
Old 03-03-2005, 01:48 PM   #9
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,775

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
I did not notice the space, cavalier is right, re-edit /etc/sudoers and see
 
Old 03-03-2005, 02:05 PM   #10
amwink
Member
 
Registered: Mar 2005
Location: Connecticut/USA
Distribution: Ubuntu 9.04
Posts: 68

Original Poster
Rep: Reputation: 15
It's now working!!

It becomes to work after the line "ander ALL=(ALL) ALL"

Thank you all for the help!

PS: I also tested with and without spaces: no difference noticed.
 
Old 03-04-2005, 02:01 AM   #11
Oakstaff
Member
 
Registered: Nov 2003
Location: Tulsa, Ok
Posts: 121

Rep: Reputation: 15
ok i just tried to do all this and get things working for me and I keepin gettin an error. I am on Slack 10.0 btw and I don't want to give my user the ability for ALL commands just the shutdown and such atm.

Here is what i added into the "User Privilege Specification"
Code:
oakstaff home = NOPASSWD: /sbin/shutdown -h now, /sbin/poweroff, /sbin/reboot
when i try and run the /sbin/shutdown command i get this cyntax error
Code:
>>> sudoers file: syntax error, line 18 <<<
>>> sudoers file: syntax error, line 18 <<<
sudo: parse error in /etc/sudoers near line 18
what am I doing wrong? i don't notice anything wrong but something is somewhere...any help would be appriciated.

PS my hostname is home, and user is oakstaff
 
Old 03-04-2005, 03:55 AM   #12
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,775

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
Try to add more space after oakstaff, like 2 or 3.
I have the same line in my /etc/sudoers, but with 2 spaces after the user name
 
Old 03-04-2005, 04:07 AM   #13
KMcD
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slack -- current
Posts: 354

Rep: Reputation: 30
Re: Allowing users to shutdown - Slack 10.1

Quote:
Originally posted by amwink
Is there a way to allow ordinary users (ie: non-root) to shutdown and poweroff/restart the system?

Tks.
as root:

Code:
chmod a+s /sbin/shutdown
chmod a+s /sbin/halt
Now any user can use the reboot and shutdown commands. The command reboot is simply a symbolic link to the halt command, which is why the permissions for halt had to be changed.
 
Old 03-04-2005, 10:07 AM   #14
amwink
Member
 
Registered: Mar 2005
Location: Connecticut/USA
Distribution: Ubuntu 9.04
Posts: 68

Original Poster
Rep: Reputation: 15
keefaz

I don't know why, but for me it only works with the line ander ALL=(ALL) ALL, regardless of the number of spaces between the username and hostname in the other line.

And it asks for the ander's password when I type sudo /sbin/shutdown -(any option), even though I added the option NOPASSWD to the sudoers file. If I type the password correcty, the system goes down.

I tried also chmod, as KMcD suggested, but it didn't work for me.
 
Old 03-04-2005, 03:06 PM   #15
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,775

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
amwink

Which text editor do you use to edit /etc/sudoers ?
Also you have to invoke the command the same way it is defined in
/etc/sudoers

Last edited by keefaz; 03-04-2005 at 03:08 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
not allowing me to login as other users madamson Solaris / OpenSolaris 7 10-07-2005 06:49 AM
Allowing users to shutdown the system LinuxSeeker Linux - General 3 11-11-2004 10:18 AM
Allowing all users to use 'shutdown' command mrde50garfield Mandriva 5 01-08-2004 10:58 AM
allowing non-root users to mount drives and shutdown rlpt Slackware 3 09-21-2002 07:35 PM
Allowing Users commands Atroxic Linux - Newbie 2 02-02-2002 12:06 AM

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

All times are GMT -5. The time now is 11:32 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