LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Shutdown without su (http://www.linuxquestions.org/questions/slackware-14/shutdown-without-su-757413/)

christevensabenz 09-23-2009 11:33 PM

Shutdown without su
 
Hi Slackers,
If I'm not logged-in as root, how can I shutdown my box without su?
It is not a big deal, but nice to have still.
I've searched the threads, but couldn't find the similar ones.

Thx & Brgds,
Chris

GrapefruiTgirl 09-23-2009 11:38 PM

If you're using Slack 13, and your user is a member of the "Power" group, you should be able to have the option to shutdown, when you log out of your session.

I can't recall if there was a 'Power' group prior to Slack 13, and my memory is fading -- I always shat down as root, so I'm not too sure about that.

Sasha

paulsm4 09-23-2009 11:38 PM

You can always do an "sudo" ;-)

mudangel 09-24-2009 12:01 AM

.one way to do it, anyway...
 
I usually alter my inittab so Ctrl-Alt-Del shuts it down-
Code:

# What to do at the "Three Finger Salute".
ca::ctrlaltdel:/sbin/shutdown -h now

-so I can use the power button for standby. That's for laptops; for a desktop, if I have to shut it down, I use the power button.

andrew.46 09-24-2009 01:08 AM

Hi Sasha,

Quote:

Originally Posted by GrapefruiTgirl (Post 3695072)
I always shat down as root...

Do they have modquotes here too?

Andrew :)

cwizardone 09-24-2009 01:32 AM

Quote:

Originally Posted by GrapefruiTgirl (Post 3695072)
If you're using Slack 13, and your user is a member of the "Power" group, you should be able to have the option to shutdown, when you log out of your session...

That's the theory, but it has yet to work, and, yes, my user is in the "power" group.
:)

vik 09-24-2009 01:58 AM

I assume you mean shutting down from the command line?

The only way I've gotten it to work is to run visudo, and edit the file like this:
under this line:
root ALL=(ALL) ALL
user ALL=/sbin/shutdown, /sbin/halt

or if you want to use the wheel group, do
wheel ALL=/sbin/shutdown,/sbin/halt

christevensabenz 09-24-2009 02:19 AM

@Sasha:
My username is already member of "power" group, yet it is not working.
I'm using 13 now, and "power" group already available in previous Slack's version.

Bash always gives me output "command not found" when I execute "shutdown -h now" or "poweroff", while it works just fine with root/su/sudo.


@paulsm4:
I'm trying to find a shortcut to do this?


@mudangel:
I need to keep Ctrl+Alt+Del to function as reboot, but yes it is one way of another.


@vik:
This seems very promising, I'll try it and tell you the result soon.


===
Thanks a lot all... ^_^
/x

vik 09-24-2009 02:28 AM

you get command not found because normal users don't get /sbin in their PATH environment variable. So you have to explicitly say /sbin/shutdown as a normal user, and just shutdown as root (because /sbin is in root's PATH variable).

If you want to allow anyone in the power group to shutdown the system, do:
power ALL=/sbin/shutdown,/sbin/halt

bathory 09-24-2009 02:30 AM

Or you can set the suid bit for /sbin/halt
Code:

chmod +s /sbin/halt

egregor 09-24-2009 02:36 AM

Don't forget to create a symbolic link in e.g. /usr/bin/ to /sbin/shutdown (using ln tool), after you set user id (suid).

christevensabenz 09-24-2009 04:20 AM

Quote:

Originally Posted by vik (Post 3695183)
you get command not found because normal users don't get /sbin in their PATH environment variable. So you have to explicitly say /sbin/shutdown as a normal user, and just shutdown as root (because /sbin is in root's PATH variable).

If you want to allow anyone in the power group to shutdown the system, do:
power ALL=/sbin/shutdown,/sbin/halt


Hi vik,
Not sure where I was wrong, but it doesn't work for me.

Here is the combination of my altered sudoers file, one at a time:
#1 user ALL=/sbin/shutdown,/sbin/halt
#2 power ALL=sbin/shutdown,/sbin/halt
#3 %power ALL=sbin/shutdown,/sbin/halt
#4 user localhost=/sbin/shutdown
#5 user localhost=/sbin/shutdown -h now
#6 power localhost=/sbin/shutdown,/sbin/halt
#7 %power localhost=/sbin/shutdown,/sbin/halt
#8 user ALL=(operator)/sbin/shutdown,/sbin/halt
#9 user localhost=(operator)/sbin/shutdown,/sbin/halt
#10 power ALL=(operator)/sbin/shutdown,/sbin/halt
#11 %power localhost=(operator)/sbin/shutdown,/sbin/halt
#etc...


I don't have all day to chew the man page, which is very long indeed.
Any idea where is my mistake? T_T

/x

GazL 09-24-2009 04:57 AM

If you're sitting next to your case, why not just press the button on the front. It runs shutdown -h for you. This has worked on my box for the past couple of releases.

rrbert 09-24-2009 10:19 AM

this works on slackware 12.2
 
i have often wanted to do this too, so i just did it and tested it now. what i did is
su to root
cd /etc
visudo
add this line to the end of the file
%users ALL = NOPASSWD: /sbin/shutdown -h now

then you can just type
sudo /sbin/shutdown -h now

as a normal user

gnashley 09-24-2009 11:02 AM

christevensabenz, notice carefully the syntax -you are using 'user' instead of 'users' and the line should begin with '%'.


All times are GMT -5. The time now is 11:08 AM.