Running terminal command on startup

Discussion in 'Mac Basics and Help' started by J@ffa, Jun 30, 2009.

  1. J@ffa macrumors 6502a

    J@ffa

    Joined:
    Jul 21, 2002
    Location:
    Behind you!
    #1
    Hey all. I'm trying to figure out something that probably has a fairly simple solution. There's a terminal command I need to run when a server I've configured (a Mac one, of course) starts up. After some googling, I established that I needed to make a plain text file with the terminal command(s) in, rename it as mychosenfilename.command, and add it to the logged-in user's startup items.

    So far so good, except the command in question is a sudo command, requiring that I type it in my password each time, making it more of an assisted startup item. Anyone know how I can, I guess, pre-approve this command to run without my intervention?
     
  2. gotenks05 macrumors member

    Joined:
    Jan 1, 2009
    #2
    Doing that is not very secure, but if you really want to find out, I think this page might help you. I can't tell for sure, because I have no reason for sudo to run without a password. Just to be clear though,
    Code:
    sudo -s
    will switch the user to the root user, which is even less safe than using sudo.
     
  3. belvdr macrumors 601

    Joined:
    Aug 15, 2005
    #3
    Add your commands to the end of /etc/rc instead of using StartupItems.
     

Share This Page