Skip to content

Instantly share code, notes, and snippets.

@andreipa
Last active March 23, 2021 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreipa/47ce0679d1905883c18b9ac3a1a9a8f6 to your computer and use it in GitHub Desktop.
Save andreipa/47ce0679d1905883c18b9ac3a1a9a8f6 to your computer and use it in GitHub Desktop.
How to modify hosts file in Windows, Mac and Linux
###### For Windows 10 and 8
1. Press the Windows key.
2. Type Notepad in the search field.
3. In the search results, right-click Notepad and select Run as administrator.
4. From Notepad, open the following file: c:\Windows\System32\Drivers\etc\hosts
5. Make the necessary changes to the file.
6. Click File > Save to save your changes.
###### For Windows 7 and Vista
1. Click Start > All Programs > Accessories.
2. Right-click Notepad and select Run as administrator.
3. Click Continue on the Windows needs your permission UAC window.
4. When Notepad opens, click File > Open.
5. In the File name field, type C:\Windows\System32\Drivers\etc\hosts.
6. Click Open.
7. Make the necessary changes to the file.
8. Click File > Save to save your changes.
###### For Windows NT, Windows 2000, and Windows XP
1. Click Start > All Programs > Accessories > Notepad.
2. Click File > Open.
3. In the File name field, type C:\Windows\System32\Drivers\etc\hosts.
4. Click Open.
5. Make the necessary changes to the file.
6. Click File > Save to save your changes.
###### MAC OS
1. Launch Terminal, type sudo nano /private/etc/hosts and press Return.
2. Enter your admin password to execute it, as with all sudo commands.
3. Use the arrow keys on your keyboard, to navigate and edit the file.
4. Like with the Windows method above you should just add the desired IP followed by the host name (or domain name).
5. Press Control-O to save the file.
6. Use your Web browser to test the changes and flush the cache with dscacheutil -flushcache if they still haven’t taken into effect.
###### Linux
1. Launch Terminal, type sudo vim /etc/hosts and press Enter.
2. Enter your administrator password (if needed).
3. Like with the Windows & MAC method above you should just add the desired IP followed by the host name (or domain name).
4. Press Control-O to save the file.
5. Use your Web browser to test the changes and flush the cache with dscacheutil -flushcache if they still haven’t taken into effect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment