[Tutorial] How To Edit Hosts File on Windows & Linux
Sometimes you will be needed to block few websites that should not be opened by user using your pc or any other, for this small thing we search for different softwares and use them to setup that blocking of site. But with small knowledge of editing Hosts file can skip the whole Software thing and you may control your network traffic in better manner.
These Hosts file were used to resolve hosts names before DNS. Also these files helps in network name resolution too.
Have you saw: 5 Ways to Bypass Cyberoam Network Security
In all types Operating systems, you will observe the hosts file with similar syntax and content. Usually, it contains strings of loopback like “127.0.0.1 localhost“, here the first part will be the location to redirect the address to and second part will be the address that you will want to redirect.
The location of hosts file is different for different operating system where we are giving guide on Windows and Linux only.
Hosts file can be accessed and edited with only Admin Privileges as it is type of system file stored under :
For editing it, you will be needed editor where Notepad is best editor available on Windows OS but you will have to execute it with “Admin Privileges” (Run As Administrator)
After executing Notepad with Admin Privileges, type the path of hosts file shown above and you will get access to it as shown in above image.
You will have to add the hosts string in the last as we shown in image and then you may save it. [Note: If you have not executed Notepad with Admin Rights then you may get errors such as “Access Denied“]
After changing hosts file you may see if it’s working or not by entering that blocked URL in any browser.
Linux Operating System
As like we require Admin Privileges on Windows OS, here also we need ROOT (SU) permissions to access and edit hosts file
Usually hosts file in linux is stored under:
For editing it, login with Root user and then execute some shell commands on Bash Shell (Terminal) shown in following GIF Tutorial:
We will be needed editor to edit it, here in linux we have VIM editor like Notepad On Windows OS.
Execute the following commands as:
3)Now, you will get in VIM editor to edit hosts file.
For getting in edit mode, you will have to press “i” to get in Insert mode then you may edit it as shown above.
4)After adding Hosts string in hosts file, you will have to save it, so save it as:
Hit “Esc” then type “:wq” (wq= write quit) and your file will be saved then.
5)Now check in any browser if it is working or not by opening blocked web url.
Many times we needed to change the hosts file for different purposes including Blocking or controlling access of network for individual user or may be group too.
These simple tutorials will give you more chances to have better knowledge on basic commands and you may do it without any use of External Software.
Latest posts by Pavan Jadhav (see all)
- 5 Facts you should know about Ireland before booking a holiday - Dec 11, 2018
- 3 Tips to Playing at a Budget Casino in New Zealand - Dec 10, 2018
- 4 Tips to Find a New Job Quickly - Dec 3, 2018