HackingUniversity - Hacks . Tricks . How-To's

20 April 2020

How to Edit & Alter the HOSTS File in Windows & Mac OS X

HOSTS File is a simple text file in Windows & Mac OS X that is used to map Hostnames to IP Addresses. When you type any URL in your browsers search bar then it checks whether there is any relevant entry in the HOSTS file and gets you the corresponding IP address, else it resolves that IP using the active connections DNS Servers. Another use of HOSTS file is to block the few Hostnames i.e if you are giving Internet access in schools or colleges or to any of your employees in your business premises, then you can block certain sites.

editing and altering hosts file on windows and mac

Editing HOSTS File in Windows Computer

If you are using Windows Computer the we are going to tell you how you can edit your HOSTS file to add few line and blocking sites from getting accessed, its also useful to cracking few software's, as we can block there servers from accessing the software and checking if serial key entered is legit or not.

  1. Open Notepad as Administrator.
  2. Navigate to C: > Windows > System 32 > drivers > etc
  3. Choose “All Files” from below and then double click on the HOSTS file.
  4. Now you will have the file live in the above image, you can add all the lines.
  5. Like you can see I have added Corel Lines to block Corel from Accessing Software.

So you can add all those lines that you want to stop from accessing your computer and software, it all depends on you, so this is the way you can access HOSTS file and alter it, make sure you open it as Administrator else it won’t let you Save the file.

Editing HOSTS File on Mac OS X - Leopard

If you are on Mac OS X - Leopard then you can follow steps mentioned below to Alter your HOSTS File, its quiet simple, so follow all the steps carefully.

  1. Open the Terminal.app, you can find Terminal app by searching “Terminal” in your spotlight or you can navigate to Applications > Utilities > Terminal.
  2. Now you need to enter below line to access the HOSTS file from your Terminal. $ sudo nano /private/etc/hosts
  3. If you prompted to enter the password, enter your password.
  4. Now you will have the HOSTS file opened, you can Alter that like I have explained above, add lines and modify the one you want. It all depends on the instructions.
  5. After you have made all the changes simply Save your HOSTS File.
  6. Now you need to Flush the DNS Cache, its pretty simple in the same Terminal app you need to enter below line to Flush your DNS. $ dscacheutil -flushcache
  7. Now you have successfully altered your HOSTS File.

So guys now you successfully learned how you can edit or alter your HOSTS file on both Windows and Mac OS X, so try it yourself and remember this will be useful in many cases and in many of my posts, I usually tell you to alter your HOSTS file in order to make many software's full version.