Вы находитесь на странице: 1из 3

12/6/2018 /etc/hosts on Windows · GitHub

Instantly share code, notes, and snippets.

zenorocha / etc-hosts-on-win.md
Last active 9 days ago

/etc/hosts on Windows

etc-hosts-on-win.md

1. Get your IP Address


echo `ifconfig $(netstat -nr | grep -e default -e "^0\.0\.0\.0" | head -1 | awk '{print $NF}') | grep -e "inet " | se

2. Modify your hosts file

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.

https://gist.github.com/zenorocha/18b10a14b2deb214dc4ce43a2d2e2992 1/3
12/6/2018 /etc/hosts on Windows · GitHub

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.

ashikcse20 commented on Sep 9

Thanks.

metalgina commented on Sep 27

wow, well, you guys seem to be having all this fun editing your 'hosts' file, the problem is, and I'm running windows 7 because windows 10 is
absolute GARBAGE, I, for the life of me, can't SAVE the file!! I've tried it in DOS, I've tried using cmd, I've tried powershell, I've tried just using
notepad, I've tried attribing it to different attribs to make it so I can write to the file, I've even tried editting the autoexec.bat to edit the file to
add the correct address for my WMP and NOTHING!! I am so frustrated! I've been working on this thing for three hours I'm ready to light my
computer on fire and run down the street naked!!! HELP!!!!

Benjaminlooi commented on Sep 29

@metalgina try cmd, powershell, notepad with Administrative privaledges?

marieclairembanga commented on Oct 25

I can't see the repo etc in notepad. Additionally when i navigate on my explorer I see the file hosts but it's encoding when I open it

frankarma commented on Oct 27

To edit the hosts file in Windows 10 you need to do it from another OS, no matter if it is a live USB or just another OS in your computer, this is
due to the fact that the system automatically opens this file just when you start your machine, and therefore it cannot be modified at the same
time. To override this, you only need to do what I just mentioned, so that the hosts file doesn't get open and you can easily modify it. The same
happens with the rest of the system files.
I hope I'm helpful.

JoelAzaria commented on Oct 29

To edit the hosts file in Windows 10 you need to do it from another OS, no matter if it is a live USB or just another OS in your computer,
this is due to the fact that the system automatically opens this file just when you start your machine, and therefore it cannot be modified at
the same time. To override this, you only need to do what I just mentioned, so that the hosts file doesn't get open and you can easily
modify it. The same happens with the rest of the system files.
I hope I'm helpful.

I'm on windows 10 and have customers on Win10. I see zero evidence that any of this has any basis in reality.
I edit my hosts file just fine from an admin cmd prompt.

lopugit commented 27 days ago

https://gist.github.com/zenorocha/18b10a14b2deb214dc4ce43a2d2e2992 2/3
12/6/2018 /etc/hosts on Windows · GitHub
To edit the hosts file in Windows 10 you need to do it from another OS, no matter if it is a live USB or just another OS in your computer,
this is due to the fact that the system automatically opens this file just when you start your machine, and therefore it cannot be modified at
the same time. To override this, you only need to do what I just mentioned, so that the hosts file doesn't get open and you can easily
modify it. The same happens with the rest of the system files.
I hope I'm helpful.

bro you are cooked

lopugit commented 27 days ago

To edit the hosts file in Windows 10 you need to do it from another OS, no matter if it is a live USB or just another OS in your
computer, this is due to the fact that the system automatically opens this file just when you start your machine, and therefore it
cannot be modified at the same time. To override this, you only need to do what I just mentioned, so that the hosts file doesn't get
open and you can easily modify it. The same happens with the rest of the system files.
I hope I'm helpful.

I'm on windows 10 and have customers on Win10. I see zero evidence that any of this has any basis in reality.
I edit my hosts file just fine from an admin cmd prompt.

@frankarma is cooked

beanstalkim commented 21 days ago

wow, well, you guys seem to be having all this fun editing your 'hosts' file, the problem is, and I'm running windows 7 because windows 10
is absolute GARBAGE, I, for the life of me, can't SAVE the file!! I've tried it in DOS, I've tried using cmd, I've tried powershell, I've tried just
using notepad, I've tried attribing it to different attribs to make it so I can write to the file, I've even tried editting the autoexec.bat to edit
the file to add the correct address for my WMP and NOTHING!! I am so frustrated! I've been working on this thing for three hours I'm
ready to light my computer on fire and run down the street naked!!! HELP!!!!

I had the same problem. The workaround is pretty simple, copy the file to your desktop, edit it, then move it back.

Don't ask me why. :)

priteshjha4u commented 10 days ago

Alright, Do i need to restart my system after making the changes? It doesn't seem to be working instantly.

JonBee commented 9 days ago

@beanstalkim @metalgina The hosts file is owned by SYSTEM. In order to edit it with notepad, you'll need to run notepad as an administrator.

@priteshjha4u Running "ipconfig /flushdns" in command prompt should force Windows to reload the hosts file, if I remember correctly.

https://gist.github.com/zenorocha/18b10a14b2deb214dc4ce43a2d2e2992 3/3

Вам также может понравиться