Editing files?

Discussion in 'macOS' started by TheAnvil, Mar 12, 2014.

  1. TheAnvil macrumors regular

    Joined:
    Nov 25, 2013
    #1
    Hi,

    New to OSX here, just got my Mini :D

    But I can't seem to edit /etc/hosts file. But I get the following message:
    Code:
    You don't own the file "hosts" and don't have permission to write to it.
    I have tried doing "open -e hosts", "sudo -e hosts" and even "sudo su" & "open -e hosts"; all to no avail

    What have I missed?

    Thanks!
     
  2. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #2
    Give this a try.

    Are you logged in to an admin account?
     
  3. TheAnvil thread starter macrumors regular

    Joined:
    Nov 25, 2013
    #3
    That article helped.

    I could edit the files in nano, however I still don't understand why I couldn't with "sudo open -e".

    Thanks.
     
  4. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #4
    Because the of way 'open' works compared to a Terminal program like nano or vi. Programs started with 'open' wouldn't have root privs. The system isn't designed to do that.
     
  5. TheAnvil thread starter macrumors regular

    Joined:
    Nov 25, 2013
    #5
    Yep. I found this:

    So, this works perfectly well.
    Code:
    sudo -b  /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts
     

Share This Page