Blog 1

Random Talk on Random Thoughts

My Host File Edited

| Comments |


A preview of a blog is often needed before it’s published.


However, it is possible that one doesn’t like to type localhost in the address bar, and would like to have other names.


The idea is in Local Setup – edit your hosts file in How to test localhost from any device on your network written by Wes Bos. On *nix, the file path is still the same as on OSX, but many users would rather use Vim for editing /etc/hosts. One may even use sed with the -i flag and the sudo privilege in order to directly manipulate this file.

  • sudo sed -i "3i127.0.0.1\" /etc/hosts for insertion of “” before the third line.
  • sudo sed -i "3c127.0.0.1\" /etc/hosts for changing the third line to “”.

Note that the tab is escaped as \t in these two commands.