LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-24-2009, 11:06 AM   #16
dwr1
Member
 
Registered: Aug 2009
Distribution: slack-current
Posts: 46

Rep: Reputation: 17

I just press the power button.

The sudoers file would be my second choice.
 
Old 09-24-2009, 12:13 PM   #17
rg3
Member
 
Registered: Jul 2007
Distribution: Fedora
Posts: 527

Rep: Reputation: Disabled
If you have HAL installed and your user is a member of the "power" group, you should be able to shutdown from the console by running something like this:

Code:
dbus-send --print-reply --system --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
Of course, you may want to create an alias or script to avoid typing so much.

Edit: apart from Shutdown, the following messages may work too: http://people.freedesktop.org/~david...ce-systempower
 
Old 09-24-2009, 05:30 PM   #18
vik
Member
 
Registered: Apr 2008
Distribution: Gentoo, FreeBSD
Posts: 225
Blog Entries: 8

Rep: Reputation: 50
Sorry, when I wrote "user" I meant just type the account of the user you want to give shutdown privileges to. Then shutdown with "sudo /sbin/shutdown -h now". That's how I've always done it. I'll double-check the syntax of this again when I get off work...

Last edited by vik; 09-24-2009 at 05:32 PM.
 
Old 09-24-2009, 06:30 PM   #19
regis_n_bits
Member
 
Registered: Mar 2006
Distribution: Slackware64-15.0
Posts: 103

Rep: Reputation: Disabled
I think these are the conditions needed to get the "Shutdown" option in KDE appearing for a user:
1) The user must be part of the power group.
2) The box boots at inittab run-level 4 (i.e. boots into X or KDE).

If your box starts using run level 3 (the default), and you use the command "startx" to start KDE, the shutdown option would not appear. The only exit option is to exit the session.
 
Old 09-24-2009, 06:35 PM   #20
manwithaplan
Member
 
Registered: Nov 2008
Location: ~/
Distribution: Arch || Sidux
Posts: 393

Rep: Reputation: 45
I had the same problem with the sudoer's file. I use:

Quote:
%users localhost=(ALL) NOPASSWD:/sbin/shutdown -h now, /sbin/reboot
 
Old 09-25-2009, 04:04 AM   #21
christevensabenz
LQ Newbie
 
Registered: May 2006
Posts: 5

Original Poster
Rep: Reputation: 1
@rrbert:
Thanks a lot, now it is working just as I expected.
I altered my sudoers file like this:
%power ALL=NOPASSWD:/sbin/shutdown,/sbin/halt
And use sudo /sbin/shutdown -h now, to shutdown as standard user.

@vik:
It came to me after two trials that I need to change "user" accordingly as you mentioned, and add "%" before groupname from the sample in sudoers file itself.

@gnashley:
I'm referring to username when typing "user" in last post, you must be thinking that I'm referring to "users" group.

@GazL & @dwr1:
Hmm, it feels like you guys tell me to drink from the bottle directly, when I'm trying to ask for a crystal glass to have my red wine... ^_^

@ALL:
Thanks for all of your time and suggestions, Slack could not be more fun and rock-solid without all of you.

/x
 
Old 09-25-2009, 05:43 AM   #22
Peacepunk
Member
 
Registered: Apr 2006
Location: Cambodia
Distribution: Slackware 12.2 &... VirtualBox!
Posts: 51

Rep: Reputation: 16
Smile

Thanks for this extensive reports on shutdown technology.

Me too, I looked for a clear answer to that question a while ago and didn't find such clear (and sometimes not concise at all) bits of CLI help. So I stuck with su.

[Kudos to rg3 for dbus-send --print-reply --system --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown that's my favourite so far. While indeed I havent tried it.]



To cut it short, su is not your ennemy. For those of you that don't like pushing a (sometimes faraway) button, or play with sudoers files, I've always done this:

(which is close to sudo but doesn't require any edit of configs)

Quote:
su -c 'halt'
And it's in the feeble range of my goldfish-grade brains memory, so I never forget this one.

I know it's not what you asked for, but still simple.
Albeit you have to give the password.


Cheers; I am bookmarking this post for my next install.

Jean-Philippe
http://www.tropicalicecube.net

Last edited by Peacepunk; 09-25-2009 at 05:49 AM. Reason: typo
 
Old 09-25-2009, 08:59 AM   #23
rworkman
Slackware Contributor
 
Registered: Oct 2004
Location: Tuscaloosa, Alabama (USA)
Distribution: Slackware
Posts: 2,559

Rep: Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351
Well, here's another approach that's only slightly different than some already posted:
Some of the content isn't relevant for this particular issue, but you might find it handy anyway

Note the "reboot" and "halt" aliases defined here:
Code:
liberty $ cat /etc/profile.d/local.sh 
# /etc/profile.d/10-local.sh

# This file contains local startup aliases and other such things          
# that are local modifications -- these apply to *all* users

alias "gui=startx -nolisten tcp -- :$(tty | colrm 1 8)"

if [ -e $HOME/.logout ]; then
  if [ ! "$SHELL" = "/bin/bash" ]; then
    alias "logout=. $HOME/.logout;clear;exit"
  else
    alias "logout=. $HOME/.logout;clear;logout"
  fi
else
  if [ ! "$SHELL" = "/bin/bash" ]; then
    alias "logout=clear;exit"                          
  else
    alias "logout=clear;logout"
  fi                                                         
fi                                                         

if [ -e $HOME/.logout ]; then              
  alias "reboot=. $HOME/.logout ; sudo /sbin/shutdown -r now"
  alias "halt=. $HOME/.logout ; sudo /sbin/shutdown -h now"
else
  alias "reboot=sudo /sbin/shutdown -r now"
  alias "halt=sudo /sbin/shutdown -h now"
fi

if [ "$USER" = "rworkman" ]; then                                                                              
  export PATH="${PATH}:/usr/sbin:/sbin"
fi
Now here are the relevant parts of /etc/sudoers:
Code:
bash-3.1# grep power /etc/sudoers 
%power	ALL=(ALL)	NOPASSWD:/etc/acpi/actions/s2disk.sh
%power	ALL=(ALL)	NOPASSWD:/etc/acpi/actions/s2ram.sh
%power  ALL=(ALL)       NOPASSWD:/sbin/shutdown -h now
%power  ALL=(ALL)       NOPASSWD:/sbin/shutdown -r now
Result: I can type "halt" or "reboot" as my normal user account, and the aliases defined in /etc/profile.d/local.sh cause the sudo commands to be invoked.
 
  


Reply

Tags
poweroff, shutdown, sudo


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
'shutdown' command causing unclean shutdown silentwol Linux - Software 3 07-01-2009 02:01 AM
User shutdown - 'cp -i -p shutdown /usr/sbin/shutdown2 - why does this not work, can? mitchellray Linux - Desktop 4 03-20-2009 09:31 PM
My Linux box does not shutdown i do when i do /sbin/shutdown -h now yawe_frek Linux - Hardware 6 09-14-2007 07:48 AM
Linux full shutdown vs. manual shutdown? LQtoto Linux - General 9 01-26-2005 06:21 PM
konsole shutdown possible? or key combo = shutdown possible? Laptop2250 Linux - Newbie 3 11-16-2003 10:44 AM

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

All times are GMT -5. The time now is 08:31 PM.

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