A bit of history:
The hosts file is a configuration file used by computer operating systems to connect domains with IP addresses. It originates in a time around ARPANEt – the pre-cursor of the internet, when the internet was composed of a few websites and domains. As the internet grew the maintenance of each hostfile (on each server) became unattainable and the distributed Domain Name System was created to simplify this.
This file can still be useful today however, and is a neat trick to override the DNS system. It can be used to force the computer you are using to point to a specific IP address for a website or domain name and can even be used to deny access to a website domain completely by pointing it to an invalid /internal IP.
An example hostsfile wth some entries (don’t use these this is purely an example!)