Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
03-03-2005, 11:24 AM
|
#1
|
Member
Registered: Mar 2005
Location: Connecticut/USA
Distribution: Ubuntu 9.04
Posts: 68
Rep:
|
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.
|
|
|
03-03-2005, 11:50 AM
|
#2
|
Senior Member
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460
Rep:
|
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.
|
|
|
03-03-2005, 11:52 AM
|
#3
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,775
|
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
|
|
|
03-03-2005, 12:45 PM
|
#4
|
Member
Registered: Mar 2005
Location: Connecticut/USA
Distribution: Ubuntu 9.04
Posts: 68
Original Poster
Rep:
|
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
|
|
|
03-03-2005, 12:49 PM
|
#5
|
Member
Registered: Mar 2005
Location: Connecticut/USA
Distribution: Ubuntu 9.04
Posts: 68
Original Poster
Rep:
|
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
|
|
|
03-03-2005, 01:28 PM
|
#6
|
Senior Member
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145
Rep:
|
You're aparently doing fine, just a doubt, is ander your username and schwarz your hostname? Double check that.
|
|
|
03-03-2005, 01:33 PM
|
#7
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,775
|
[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.
|
|
|
03-03-2005, 01:43 PM
|
#8
|
Member
Registered: Feb 2005
Location: Denver, CO
Distribution: Slack 12, tweaked just so (though I'm also a fan of Ubuntu)
Posts: 198
Rep:
|
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.
|
|
|
03-03-2005, 01:48 PM
|
#9
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,775
|
I did not notice the space, cavalier is right, re-edit /etc/sudoers and see
|
|
|
03-03-2005, 02:05 PM
|
#10
|
Member
Registered: Mar 2005
Location: Connecticut/USA
Distribution: Ubuntu 9.04
Posts: 68
Original Poster
Rep:
|
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.
|
|
|
03-04-2005, 02:01 AM
|
#11
|
Member
Registered: Nov 2003
Location: Tulsa, Ok
Posts: 121
Rep:
|
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
|
|
|
03-04-2005, 03:55 AM
|
#12
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,775
|
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
|
|
|
03-04-2005, 04:07 AM
|
#13
|
Member
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slack -- current
Posts: 354
Rep:
|
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.
|
|
|
03-04-2005, 10:07 AM
|
#14
|
Member
Registered: Mar 2005
Location: Connecticut/USA
Distribution: Ubuntu 9.04
Posts: 68
Original Poster
Rep:
|
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.
|
|
|
03-04-2005, 03:06 PM
|
#15
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,775
|
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.
|
|
|
All times are GMT -5. The time now is 11:32 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|