Shutdown in Terminal without password

Discussion in 'macOS' started by krayziekray, Jul 7, 2009.

  1. krayziekray macrumors 6502

    Joined:
    Sep 24, 2008
    Location:
    127.0.0.1
    #1
    So, I want to be able to turn off my Mac using Terminal without it asking for a password.

    At the moment when i type:

    sudo shutdown -h now

    I get prompted for a password.

    I need to add this to a Perl script that I'm writing for myself and need to know if there is anyway i can accomplish shutting down the Mac without having to provide my Password.

    Thanks in advance guys.

    :apple: KrayzieKray :apple:
     
  2. belvdr macrumors 603

    Joined:
    Aug 15, 2005
    #2
    Write your script, and change it to setuid to root. Note that anyone with access to the script will be able to shut it down.

    Code:
    chmod 4755 <script_name>
    
     
  3. krayziekray thread starter macrumors 6502

    Joined:
    Sep 24, 2008
    Location:
    127.0.0.1
    #3
    Thanks belvdr for the quick response ... what if this Perl script was to be added into the Automator app (Run Shell Script option). Would there be any way to do it in there? As i cant change the permisson of the script in there.
     
  4. belvdr macrumors 603

    Joined:
    Aug 15, 2005
    #4
    That I don't know, as I have no experience with Automator. Maybe if you created the perl script, made it setuid root, and had automator call the perl script.
     

Share This Page