Wednesday, July 28, 2010

Editing hosts file on Mac

After using MS Windows for past 7-8 years i have become lazy. I almost forgot all the commands i used to execute in good old DOS and UNIX days!

Then this day came - i had to edit my hosts file on the mac for making some program work. It was pretty easy in the windows - just go to a folder deep inside the Windows/system32/drivers, open the hosts file as an administrator and make your edits. Replace the existing file with the newly modified file!

But then it was more easier on the mac until i used the terminal commands - this is what i did:

  1. Open terminal
  2. Type in -  sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts
  3. The terminal shall ask for password - enter your password
  4. The hosts file will open in TextEdit
  5. Ad your entries between localhost and broadcasthost
  6. Save file using command + s key combination
  7. Close the file, Quit the textedit app
  8. Execute this command in terminal  - sudo dscacheutil -flushcache

You are all set! Isn't it so easy :)  I love this command line usage. It reminds me of my college days!

Happy editing your hosts file.

If you have any other simple tricks that one might need on mac, do share with me. Thanks for reading this post!

No comments:

Post a Comment