A preview of a blog is often needed before it’s published.
However, it is possible that one doesn’t like to type
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
sudo privilege in order to directly manipulate this file.
sudo sed -i "3i127.0.0.1\tblogtest.com" /etc/hostsfor insertion of “127.0.0.1 blogtest.com” before the third line.
sudo sed -i "3c127.0.0.1\tblogtest.com" /etc/hostsfor changing the third line to “127.0.0.1 blogtest.com”.
Note that the tab is escaped as
\t in these two commands.