how do i edit the hosts file?

Discussion in 'Mac OS X Lion (10.7)' started by Benz63amg, Jul 23, 2011.

  1. Benz63amg macrumors 68000

    Benz63amg

    Joined:
    Oct 17, 2010
    #1
    hey guys, i know how to do it in snow leopard but now in lion i cant seem to be able to edit the hosts file, it says its in use when i try to replace it after i edited it. how do i do it in lion?
     
  2. ayeying macrumors 601

    ayeying

    Joined:
    Dec 5, 2007
    Location:
    Yay Area, CA
    #2
    You need to do this under Super User (su) or sudo or root.
     
  3. bully worm macrumors regular

    Joined:
    Sep 17, 2009
    #3
    Trying to stop a certain app from phoning back home eh?
     
  4. newfoundglory, Jul 23, 2011
    Last edited: Jul 23, 2011

    newfoundglory macrumors 6502

    Joined:
    Nov 5, 2007
    #4
    the easiest way to ADD something to the hosts file, is to put your additions in another file (eg. put the lines to add in add.txt in your home directory). Then using Terminal type

    Code:
    $  sudo -s
    [enter your password]
    #  cat ~/add.txt >> /etc/hosts
    
    Make sure you use two >> and not one > :)

    Alternatively, use vi for editing.
     
  5. GermanyChris macrumors 601

    GermanyChris

    Joined:
    Jul 3, 2011
    Location:
    Here
    #5
    I'm sure, and it works just as well in 10.7 as it did in 10.6
     
  6. Simplicated macrumors 65816

    Simplicated

    Joined:
    Sep 20, 2008
    Location:
    Waterloo, Ontario, Canada
    #6
    The OP might needed to restore his iPhone to a version prior to 4.3.4... :D
     
  7. Jerome Morrow macrumors 6502a

    Jerome Morrow

    Joined:
    Jun 13, 2011
    Location:
    United Kingdom
    #7
    Edit in peace - http://www.macupdate.com/app/mac/29949/gas-mask
     
  8. stillmatic macrumors member

    Joined:
    Apr 27, 2010
    #8
    open Terminal and type 'sudo pico /etc/hosts'
     
  9. IrishTiger macrumors regular

    Joined:
    Apr 23, 2010
    Location:
    Atlanta, GA
    #9
    I'm going to resurrect this thread as it became useful.

    I bought a MacBook Air over the weekend, and I did the migration assistant from my MacBook Pro - however I needed to fix some software issues, Lion wouldn't let me do it the old way I did, but Gas Mask, the free downloadable app worked like a charm!!!!! Everything is back to normal.

    Here's the link:
    GAS MASK
     

Share This Page