Coming soon, fast templates with an unlimited number of modules for 1 UAH/order

How to set the data in the hosts file on Mac OS ?

If, for example, you need to make the line 173.249.3.24 new.домен.com.ua in the hosts file on Mac OS, there are two ways to solve this problem.

Option 1. Via the terminal.

How to open the hosts file using terminal on Mac OS?

To view and edit the hosts file on your Mac, open the program "Terminal" (Applications(Programs) Utilities(utilities) - Terminal(Terminal)) and type the following command.

sudo nano /private/etc/hosts

Also you will need to enter the admin password, if set on the computer.

If you have entered everything correctly, you will see the contents of the hosts file of your Mac.

Make the necessary changes in this file (the cursor in the terminal doesn't work, to move between lines use the arrows on the keyboard).

After making all necessary changes, hit "ctrl X" to save.

Press "Y" to confirm saving changes.

That's all the hosts file is updated successfully.

In order to make the changes immediately took effect, it is sometimes necessary to reset the DNS cache on your Mac - for this type in the same Terminal (after quitting the program editing the hosts file)

dscacheutil -flushcache

Option 2. Using a text editor

How to open the hosts file in a text editor?

To do this, click the right mouse button (or use the same action on the trackpad) on the Finder icon on the bottom panel (Dock) your computer and select from the drop down menu "go to folder...".

In the opened window enter the path where is the hosts file in computers running OS X and click "Go". The path looks in the following way.

/private/etc/hosts

This will open a Finder window and in the folder where the desired file is located. It will be already allocated. Just click right button and open it using your favorite text editor (and standard approach TextEdit).

The file itself is protected from editing. However, when you try to make changes you will be prompted to create a copy - do so. Make the necessary changes to the copy of the file and save it, for example, on the desktop as a file called hosts. Разрешение.txt the saved file then delete it.

In the last paragraph of this instruction you just need to replace the old hosts file on the newly created by simply dragging it from the desktop to the folder where is the original file. In the popup window confirm the action by pressing the button "Replace".

That's all. The result of these steps, your computer will use the new hosts file. But sometimes, in order for the changes to take effect immediately, you may need to refresh your DNS cache.

To do this, in terminal run the following command (requires administrator password)

dscacheutil -flushcache