PDA

View Full Version : oops I mucked up my hosts file



dugimodo
24-01-2016, 12:32 AM
On my media PC which is an intel NUC running windows 10 I just use the default MS browsers as space is limited and I really don't do much web surfing on it.
Annoyed with some pop up adds I cleverly downloaded a hosts file and replaced the default one, now anything to do with the internet is completely unusable. No problem I'll just put the old hosts file back right? except it won't let me, even in safe mode, and I've tried stopping every running process I can think of and it won't work. tells me the file is in use by another program.

I can't edit it in notepad and save it either, same issue. Tried disabling MS defender, no joy. Really frustrating. Any Suggestions? It's late and I've given up. I'm thinking tomorrow I might find a linux CD and use that to replace the hosts file, should work.
I'm a little worried I might have loaded something dodgy, can the hosts file do any real damage ?

Don't ask me where I got the hosts file, was a search result in BING near the top is about all I remember, normally use google but the browser must still have bing set as default.

Yes I should know better.

DeSade
24-01-2016, 02:00 AM
Could try disabling it in MSCONFIG if it gives you the option to do so.

Greg
24-01-2016, 07:09 AM
Dunno if it's the same for Win 10, but here's how to get to it in Win8.1: (you have to have full permissions Admin rights first of course)

Computer/C/Windows/System 32/Drivers/Etc/Hosts. Open it in Notepad and replace it with another Hosts - either download/copy another from the Internet or get the original from MS. Remember to save it without any extension; ie Notepad will try to save it as hosts.txt which you mustn't do.

Of course be sure that you show all Hidden files.

dugimodo
24-01-2016, 07:42 AM
I know where the file is and how to edit it or replace it, the problem is windows won't let me. Not because I don't have rights, because it says the file is in use even in safe mode after just booting.
I might have tried system restore but it's disabled on that machine. I think linux will be the way to go.

KarameaDave
24-01-2016, 07:50 AM
It sounds a bit dodgy for sure.
Linux will be the best bet to change it.
The next question though is, will whatever malicious process
that is preventing you fixing this in Windows still be active?

dugimodo
24-01-2016, 10:00 AM
All fixed, Linux to the rescue.
Running a couple of scans just in case but everything seems fine.

Driftwood
24-01-2016, 12:05 PM
Bet that was a relief.

wainuitech
24-01-2016, 01:56 PM
Just for future reference, you can edit the file > Just tried it- Worked fine:




The problem is actually very simple: in Windows 10 the hosts file is read-only by default. This means that even if you can access it with administrative privileges, you still cannot write to it. Furthermore (at least on my machine) this means that editing a copy as others suggested won't work, because it will be read-only too!

To be able to edit it you must first disable the read-only bit:

Open the c:\windows\system32\drivers\etc\ folder in your file-manager;
right-click the hosts file;
select Properties;
un-tick Read-Only;
click Apply;
click Continue (to perform the action with administrator privileges).

Then you can freely edit the hosts file with your favourite text editor (running it as an administrator). Remember to re-set the read-only bit after you're done to prevent other applications from modifying it without your knowledge.
Normally I'd do the same with Linux CD.

dugimodo
24-01-2016, 03:39 PM
I don't know what happened but I'm pretty sure that wouldn't work either Wainui. I tried editing it, tried deleting it, tried replacing it, and again in safe mode, nada.
Replacing the hosts file to begin with was simple and took a few seconds. What I couldn't do was go back no matter what I tried. There were no access denied or permissions errors, it was all variations on the file is in use by another process.

Anyway fixed now, and system restore is now enabled. Think it was off due to me thinking the 120GB SSD was a bit small, but in practice it's bigger than needed for what the PC does.

wainuitech
24-01-2016, 05:51 PM
System Restore has sometimes saved hours of work. Just check --

From the "how to suck eggs" department :p You can adjust the amount of reserved space it consumes to suit your needs.

6926

linw
25-01-2016, 03:28 PM
Every now and then, System Restore has saved me heaps of grief as well. Never understood why some people turn it off.

Win 10 new builds turn it off for some unfathomable reason so one has to remember to turn it on again.

Good to see you back in action dugi. No doubt about it, the ol' Linux disk is handy for file problems like yours!