Linux Host file entry to verify websites


Host file is a system file used by an operating system to map a hostname to an IP-addresses. The host file is a plain text file and is conventionally named hosts.

Once website migration is over, we might need to make sure everything is in place, before flipping DNS. This can be done by adding an entry in our system’s hosts file.

Acess the hostfile location

sudo vim /etc/hosts
  • Enter the password of your PC, to grant Sudo access.

  • Press the I key, to enable the insert mode.

Lets add an example host file,       localhost

 # The following lines are desirable for IPv6 capable hosts
 ::1     ip6-localhost ip6-loopback
 fe00::0 ip6-localnet
 ff00::0 ip6-mcastprefix
 ff02::1 ip6-allnodes
 ff02::2 ip6-allrouters

To save

After the host file entry is made, press the Esc key and type :wq! and hit the Enter key.

To check

Try the ping command to check if the host file entry made is right.


Ping for must point to the Ip address

PING ( 56(84) bytes of data.

Once we have tested everything, you can flip the DNS. Also, make sure to remove this entry from the host file after testing.