Hosts file is simply a text file which is used by all operating system to decode hostname into IP addresses. If you type in hostname facebook.com, then system will search for the hosts file to get IP address which needs to connect to the suitable server. Basically, while opening the host file, you notice that it doesn’t have any directory of the whole internet but just a couple of lines. For any type of search, your system first checks the hosts file and if that search isn’t defined there, will be looked up on DNS server defined in network settings.
Therefore, you can use hosts file to add to what DNS servers can’t provide or override IP addresses which DNS server normally provide. Let’s clear this with the example, if you ask facebook.com, DNS server provide Facebook IP address to the computer. But if you need to block Facebook on that computer, you have to add an entry in hosts file. So, there are number of things that you can do with hosts file.
Manage Hosts File in Linux
Hosts file is a popular feature to modify your system, depending on needs. Through hosts file, you can easily block websites, create shortcuts and more.
Edit Host File
In Linux, hosts file under /etc/hosts. You can simply use graphical text editor or terminal text editor. But, there is only one graphical tool which offers partial control of hosts file that is Linux Mint’s domain blocker application. This tool works by adding entries into hosts file which points hostnames user specify to 127.0.0.1. This is the only work you can do with domain blocker. You can make change with the text editor for any other use of host file.
Customers require administrative rights to save changes to the file. Editing can be done by using terminal commands including gksu gedit/etc/hosts or sudo nano/etc/hosts. Through terminal you, can launch application along with administrative rights. You can just replace gedit or nano with your preferred terminal text or graphical editor.
Benefits of Hosts File:
- Use of less resource- you can block advertising sites without any extra programs by using function that is built into your system. It reduces memory and processor usage and free up resources for other tasks.
- Minimize tracking and safety concerns- Hosts file can prevent tracking and advertising companies, by intercepting IP calls before they leave your computer. This will keep tracking companies from profiling you and keep you safe. Those sites which are not in hosts file can track you and send ads.
- Works on connections other than HTTP- Mostly ad blocking programs intercept IP calls going to HTTP port on your computer. Hosts file can block IP calls on any port including FTP or HTTP.
- Configurable hosts’ file- Users can edit host files completely by their own instead depending on other to block sites. They can put any site into the hosts file and can use this to block trackers, unwanted sites or advertisers. All these tasks can be done by users without depending on someone else.
- Fast browsing speed- Files that is placed in hosts’ files with proper addresses, computer does not ask another computer where to find a site. Therefore, computer will go directly to that site, and this will increase the speed of surfing experience. Blocking technique in hosts file can keep ads from being loaded in hosts.
Some drawbacks on Hosts file:
- Host file will not work with URL’s which starts with IP numbers.
- Host file may cause some sites to stop working properly.
- Host file will not work with wildcards.