You must have heard about a lot about /etc/hosts file in Linux operating system. Host File exists in “/etc/hosts” path in Linux/Unix Operating system.
The host file is used in the operating system to resolve the hostnames/DNS locally and it is quite a common practice to update your host entries with their IP and corresponding hostname in “/etc/hosts” file in any flavor of NIX OS.
Things are emerging and new technologies are coming each day to make life easier, these new tech tools sometimes make your life easier but parallel they are adding a new layer of complexity.
In this sequence recently, I had the requirement to update /etc/hosts in windows. Most Linux users will agree with me that they have not updated in windows because generally, people work with NIX systems in production, which makes it rare for them to encounter updating this file in windows.
As I mentioned earlier, technology is emerging, with new solutions, it is adding new complexities as well, just like other things do in the world.
Being a complete NIX geek, recently I had the requirement where I was supposed to update and test the /etc/hosts file in windows.
Basically I was working upon one Hadoop cluster, I installed Hadoop in public cloud infra with centos 7.6 version. In this cluster, I had FQDN for different machines which I updated in /etc/hosts file of NIX system, i.e. centos 7.X in my case.
When the Hadoop cluster came up, name node UI URL “hdp01.example.com:50070” was not working, Similarly, data node details were not loading in HTTP with URL “hdp03.example.com:1022”,yet it was working fine with IP and port combination rather than FQDN and port.
Just to mention, my FQDN was resolving within the cluster but the external machine from where I was hitting the URL is a windows machine, and hence this URL was not working in this machine as it is hosted in the cloud. Due to this reason, I had the requirement to update /etc/hosts in windows so that I can access the cloud hostname node URL with FQDN from my local windows machine as well.
With a little search online I managed to get the path of “/etc/hosts” file in windows.
As it is windows it is not quite straightforward to update this file, below are the path and steps to update the “/etc/hosts” files in windows
PATH OF /etc/hosts in Windows
To update this file, you have to run notepad as administrator as below:
- Press the Windows key.
- Type Notepad in the search field.
- In the search results, right-click Notepad and select Run as administrator.
- From Notepad, open the following file:
Do the changes as you wish to. finally, save and replace the old file.