The hosts file is used by your computer to map hostnames to IP addresses. By adding or removing lines to your hosts file you can change where sealed domains will point when you access them in a browser or using other software. This is an crucial file so you will need an bill with broad privileges to make any changes. The Mac OS X process is a little more complicate than just editing a text file, but it ‘s still easy adequate for flush complete newbies to do with little worry. The hosts file is used by your calculator to map hostnames to IP addresses. By adding or removing lines to your hosts file you can change where certain domains will point when you access them in a browser or using other software .
This is an significant file and one that is under the calculator administrator ‘s dominance, so you ‘ll need an bill with entire privileges to make any changes. On Mac OS X the serve is a little more complicate than just opening a textbook file, adding some lines and saving it again ; but it ‘s still easy enough for even complete newbies to do with little fuss .
If you ‘re running Windows you can find instructions for your operational system here.

What It Does

If you ‘ve landed on this page from a search, there ‘s a estimable theme you already know why you want to change the hosts file ( and can go ahead and skip down the page to the “ Making Changes ” section of this article ). still reading ? I ‘ll assume you ‘re not familiar with this file then .
MAKEUSEOF VIDEO OF THE DAY
mac os x hosts file
The hosts file is used to route hostnames including web site addresses to IP addresses. If an existing world is added to this file along with an IP, it will call on that IP rather than where the world name normally points. There are a range of uses, though the huge majority involve security, blocking hostnames and preventing connections being made .
As an model, web developers frequently have to use this file to access developer servers which are n’t tied to a world. By pointing a domain or sub-domain like “ mysite1.mysite.com ” to the IP at which the development site is located it is easier to entree the site. This besides helps prevent the rest of the world wide web accessing that server easily .
Another model would be to block access to a domain, thus when a web site redirects you to an adserver or spouse site, you could block that site by adding a line in your hosts file which redirects the IP to your local machine ( 127.0.0.1 ). Of course, this alone provides a loose safety net as advertisers, spammers, malware distributors and anyone else you might want to keep out are wise .
mac os hosts file
Your calculator ( be it Windows, Mac or Linux ) will always check for the hosts file on boot, and you wo n’t need to do anything to enable it. It ‘s already there. If you ‘re reading this article you ‘re credibly using a Mac, and you should know that making changes to this parcel of the phonograph record will require administrator access .
By far the easiest means of making changes to your hosts file is by using the Terminal app, rather than the Finder .

Making Changes

This tutorial is for Mac OS X Lion 10.7 and late unless otherwise specified. In decree to change the hosts file you should first open the Terminal app. At the immediate type the follow :

sudo nano /etc/hosts

When prompted, type in your administrator password and stumble Enter .
Users on Mac OS X 10.6 or earlier will find the file in the /private/etc/hosts localization alternatively .
mac os hosts file
To give you an idea of what ‘s going on here, the sudo command provides impermanent root-level access, while nano is the name of the plan used to make the changes to the file, and /etc/hosts is the location of the file .
once you ‘ve entered a password and load nano, you ‘ll see a window that looks roughly like the screenshot below .
mac os hosts file
You ‘ll have to use the arrow key to move the cursor around as your mouse arrow will not work here. Pay attention to the comments, which are signified by “ # ” symbols. If a wrinkle starts with a # it ‘s ignored, so you can use these lines to help keep the charge kempt with descriptions of what each addition does. similarly, you can use comments to cursorily enable or disable changes without removing the rule wholly. This is known as “ commenting out ” .
Rules should be added in the stick to format : , for example: adding “127.0.0.1 google.com” would redirect all google.com requests (but not www.google.com requests) to your local machine, essentially blocking your machine from accessing Google’s servers.
once you ‘ve added a commented-out description, an IP and a domain you should save the file using the keyboard shortcut Control+O which calls the WriteOut function. You will be asked for a localization and file diagnose, but seeing as you ‘re overwriting a file all you need to do is weigh Enter. Remember you ‘re only able to do this because you used the sudo command to gain admin privilege, otherwise you would not have permission to overwrite what the system considers to be a very important file .

mac os x hosts file
once you ‘ve hit Enter nano will report how many lines were written, and the changes will be saved. You can quit nano using Control+X to return to the prompt, the changes should be blink of an eye.

In the event that your changes do n’t register immediately you can flush your DNS by opening Terminal and entering the follow :

sudo killall -HUP mDNSResponder

For users on OS X 10.6 or earlier the succeed Terminal command is used to flush DNS alternatively :

dscacheutil -flushcache

All Done!

And that ‘s it, you ‘ve nowadays changed your Mac OS X hosts file and can confidently do it again whenever you want using a few Terminal commands .
Let us know what you ‘ve been doing to your hosts file in the comments, below .

MacOS VM Featured
How to Improve macOS Performance in VMware on Windows
Read Next

share

pinch

contribution

e-mail

About The author
Tim Brookes
( 821 Articles Published )

Tim is a mercenary writer who lives in Melbourne, Australia. You can follow him on Twitter .
More
From Tim Brookes

Subscribe to our newsletter

Join our newsletter for technical school tips, reviews, loose ebooks, and exclusive deals !
Click here to subscribe

informant : https://themedipia.com
Category : Website hosting

Leave a Reply

Your email address will not be published.