Perform chown & chmod on a Hidden File...

i need to change the ownership and permissions of /private/etc/hosts to have full read/write access. the file is locked and owned by System by default. i have been able to do it with chmod but it first requires unlocking it manually. i need this to happen in the background when a non-admin user logs in. i have no problem embedding the local admin name and password into the script if that would help as i could just save this out as a run-only login item. any help would be great. thanks! :slight_smile:

Hi,

Handle with care! Changing permissions in invisible folders is not recommendable

do shell script "sudo chown myOwner:myGroup /private/etc/hosts" user name "theUsername" password "¢¢¢¢¢" with administrator privileges

no guarantee for fixing unexpected behaviour :wink:

I have an idea how you can have the scripts run automatically when a user logs in and out of the computer. Look at this hint I submitted to MacOS Hints about login and logout hooks. You can use them to run your script.

http://www.macosxhints.com/article.php?story=2006081701162739

Note: login hooks execute as root so a user wouldn’t have to be an admin to run the applescript.

Awesome, Thank You both!