Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


  Search this Thread
Old 09-24-2009, 11:06 AM   #16
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
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:

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:
Old 09-24-2009, 05:30 PM   #18
Registered: Apr 2008
Distribution: Gentoo
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
Registered: Mar 2006
Distribution: Slackware64 14.2 (kernel 4.4.52)
Posts: 85

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
Registered: Nov 2008
Location: ~/
Distribution: Arch || Sidux
Posts: 393

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

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

Original Poster
Rep: Reputation: 1
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.

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.

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... ^_^

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

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

Rep: Reputation: 16

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)

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.


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

Rep: Reputation: 709Reputation: 709Reputation: 709Reputation: 709Reputation: 709Reputation: 709Reputation: 709
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:
liberty $ cat /etc/profile.d/ 
# /etc/profile.d/

# 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"
    alias "logout=. $HOME/.logout;clear;logout"
  if [ ! "$SHELL" = "/bin/bash" ]; then
    alias "logout=clear;exit"                          
    alias "logout=clear;logout"

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

if [ "$USER" = "rworkman" ]; then                                                                              
  export PATH="${PATH}:/usr/sbin:/sbin"
Now here are the relevant parts of /etc/sudoers:
bash-3.1# grep power /etc/sudoers 
%power	ALL=(ALL)	NOPASSWD:/etc/acpi/actions/
%power	ALL=(ALL)	NOPASSWD:/etc/acpi/actions/
%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/ cause the sudo commands to be invoked.


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 > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 04:47 AM.

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