Site icon Ananova Business Web Hosting

Manage Hosts File in Linux

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:
Some drawbacks on Hosts file:


Exit mobile version