hosts

In Linux, /etc/hosts is a file used by the operating system to translate hostnames to IP-addresses. It is also called the ‘hosts’ file. By adding lines to this file, we can map arbitrary hostnames to arbitrary IP-addresses, which then we can use for testing websites locally

First, let’s take a look at an example. Assuming we need to map baeldung.com to 127.0.0.1, we add the following line to /etc/hosts:

127.0.0.1    baeldung.com

Now, every time we go visit the site, our OS tells the browser to visit our localhost.