Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
Hi All, I have to make a script to shutdown in Kubuntu (it's Kubuntu-desktop installed on top of Ubuntu...shutdown buttons missing). I forget how to make a script call for ...
  1. #1
    Linux Guru jmadero's Avatar
    Join Date
    Jul 2007
    Location
    California
    Posts
    1,958

    script to call for sudo password

    Hi All,

    I have to make a script to shutdown in Kubuntu (it's Kubuntu-desktop installed on top of Ubuntu...shutdown buttons missing). I forget how to make a script call for sudo password (since shutdown requires sudo user if you do it from a command line). Thanks all
    Bodhi 1.3 & Bodhi 1.4 using E17
    Dell Studio 17, Intel Graphics card, 4 gigs of RAM, E17

    "The beauty in life can only be found by moving past the materialism which defines human nature and into the higher realm of thought and knowledge"

  2. #2
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Location
    Boston, MA
    Posts
    4,651
    I use pekwm, which doesn't handle shutdowns, so I put a couple of menu entries as so
    Code:
    gksudo /sbin/shutdown -h now
    gksudo /sbin/reboot
    EDIT: Forgot to say there is also kdesu instead of gksu/do.
    Last edited by reed9; 11-10-2009 at 11:13 AM.

  3. #3
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    I would just configure sudo to not need a password for your user when you run the shutdown and reboot commands.

    I'm not on the machine I have it set up on, but it should be something like this
    Code:
    jmadero  ALL=(ALL) NOPASSWD:/sbin/shutdown -h now,/sbin/reboot

  4. #4
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Location
    Boston, MA
    Posts
    4,651
    I would just configure sudo to not need a password for your user when you run the shutdown and reboot commands.
    This still requires you to call sudo, though, it just means it doesn't ask for authentication.

    You can also get fancy and send a message to HAL to shutdown.

    Code:
    dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
    
    dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Reboot

  5. #5
    Linux Guru jmadero's Avatar
    Join Date
    Jul 2007
    Location
    California
    Posts
    1,958
    well thank you both but, still not quite getting it:

    I've tried just making a basic file which runs "gksudo shutdown -h now", it never requests a password, shows it trying to do something then stops.

    I'd like not having to put in password so coopstah, your solution seems good, where to I put line that you posted?

    I think that this is a bug but in launchpad I think they've determined it's not...so weird that if you install Ubuntu and then Kubuntu-desktop on top of it (I like having both....let's me try new things ) you don't get shutdown options in KDE, you only get logout options...
    Bodhi 1.3 & Bodhi 1.4 using E17
    Dell Studio 17, Intel Graphics card, 4 gigs of RAM, E17

    "The beauty in life can only be found by moving past the materialism which defines human nature and into the higher realm of thought and knowledge"

  6. #6
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Location
    Boston, MA
    Posts
    4,651
    I'd like not having to put in password so coopstah, your solution seems good, where to I put line that you posted?
    You put that in /etc/sudoers

    Use visudo to edit
    Code:
    sudo visudo
    I've tried just making a basic file which runs "gksudo shutdown -h now", it never requests a password, shows it trying to do something then stops.
    Try it with kdesu instead of gksudo.

  7. #7
    Linux Guru jmadero's Avatar
    Join Date
    Jul 2007
    Location
    California
    Posts
    1,958
    thanks, working on it now, kdesu does the same thing, clock thing spins for a few seconds, shows "shutdown" (name of my launcher) in the task bar, then it goes away, never asks for a password....does this seem like a bug to you? Not having a shutdown option in my KDE setup?
    Bodhi 1.3 & Bodhi 1.4 using E17
    Dell Studio 17, Intel Graphics card, 4 gigs of RAM, E17

    "The beauty in life can only be found by moving past the materialism which defines human nature and into the higher realm of thought and knowledge"

  8. #8
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Location
    Boston, MA
    Posts
    4,651
    I think it has something to do with the session manager, consolekit, and dbus.

    In your other post, you never answered, are you still using GDM for the login manager, or KDM?

    I know in Arch, when not using KDM or GDM, you have to start the desktop with ck-launch-session gnome-session or ck-launch-session startkde to properly connect to consolekit, or the shutdown/reboot buttons don't appear. But I'm not sure that works in Ubuntu.

  9. #9
    Linux Guru jmadero's Avatar
    Join Date
    Jul 2007
    Location
    California
    Posts
    1,958
    I actually completely forgot about that post! lol that's what I get for doing too many things at once.

    For my login manager....I'm not too sure. I thought that they both use the same login manager (nothing changed after I installed kubuntu-desktop)...so if I had to guess it would be GDM login manager, but if I login as jmadero it automatically loads KDE, while my other users auto go into Gnome
    Bodhi 1.3 & Bodhi 1.4 using E17
    Dell Studio 17, Intel Graphics card, 4 gigs of RAM, E17

    "The beauty in life can only be found by moving past the materialism which defines human nature and into the higher realm of thought and knowledge"

  10. #10
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Location
    Boston, MA
    Posts
    4,651
    If you do
    Code:
    sudo dpkg-reconfigure gdm
    it should prompt you to choose your login manager. Select KDM and see if that solves the problem. If it doesn't, I would guess kdm is not installed. In which case
    Code:
    sudo apt-get install kdm

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...