How to modify hosts file in MAC?

0 votes
1,127 views
asked Feb 12, 2019 by Hitesh Garg (799 points)  

I want to add the name to the host file for an IP. How to do that in a MAC system using the command line terminal.

1 Answer

0 votes
answered Feb 12, 2019 by Hitesh Garg (799 points)  
 
Best answer

Use the following steps -

  • Launch Terminal, type sudo nano /private/etc/hosts and press Return. You’ll need to also enter your admin password to execute it, as with all sudo commands.
  • You will now have the hosts file open in the Nano editor. Use the arrow keys on your keyboard, to navigate and edit the file.
  • Go to the bottom of the file and add the desired IP followed by the host name (or domain name). Save the file and you are all set.
  • Use your Web browser to test the changes and flush the cache with dscacheutil -flushcache if they still haven’t taken into effect.

For complete reference on windows, MAC and Linux use the following link.
How to edit hosts file

...