How to add to hosts file on a MAC

From time to time it is necessary to update the hosts file on a machine, and MAC’s are no different! given they are based on unix most bits and pieces are in their usual places but “hidden” from the usual users. With good cause! If your reading this your obviously not a normal user…

So lets begin.

  1. Open Terminal and gain elevated privileges
    Click on Applications >> Utilities >> Terminal then enter the below command to gain elevated privileges.

    sudo su

    you will need to provide your root password at the prompt see below, typing the password will be blind.

  2. Enter and edit the hosts file as below.
    Enter the below command to edit the hosts file

    pico /etc/hosts

    Once in pico you will see something like the below screen shot.

  3. Once done save!
    Once you’ve finished editing the file as required hold Control and hit O then Enter, then Control and hit X to exit, and you’re done! Exit Terminal.

Job done! It isn’t difficult, however you need to use the sudo su command to gain root privileges before you will be able to successfully save the hosts file. For more information on Hosts Files check out this wiki link.


Tags: , , , , , , ,

No comments yet.

Leave a Reply