Interesting

How to change and restore the hosts file

User question

Hello.

I have the following problem: when trying to open social. networks (VK, Odnoklassniki) - instead of them, some other site appears, similar to them, and asks to send an SMS to a short number.

Doctor Web (portable version) found a problem in the HOSTS file, but cannot delete it (either manually). Tell me how to change the recover HOSTS file ...

Hello!

Actually the file hosts has a big impact on how your internet works. 👇

In short: when you try to open a website, your browser first needs to get its IP address.

To do this, he accesses the hosts file, and then to the DNS server. Those. having received the IP address from the hosts file - it will open the website / page for this IP address for you ...

In this way, various viruses and malware prescribes lines with IP addresses "necessary" for them in this file, and thanks to this, completely "left" sites are opened instead of the usual ones (although the address bar will contain, for example, Vk.com).

This article will address two key questions:

  • how to edit and modify this file;
  • how to restore it, even if it was blocked by a virus (to the version that was when Windows was installed).

*

How to open and modify the hosts file

Note: the hosts file is located at:

C: \ Windows \ System32 \ drivers \ etc \ hosts (relevant for Windows 7, 8, 8.1, 10)

Most often the inability to change this file is not due to blocking it by various virus software, but simply to the fact that your notepad (or other editing program) is not open with administrator rights.

It is because of this, when you change the lines in the hosts file, you are told an error that you do not have enough rights.

I will consider below a couple of ways how to open the hosts file with administrator rights (i.e. you can edit and save it).

Method 1: relevant for Windows 7/8/10

1) First press a combination of buttons Ctrl + Shift + Esc (or Ctrl + Alt + Del). The task manager should open.

2) Next push file / new task. In the "Create task" window that opens, enter the command in the "Open" line notepad , and check the box "Create a task with administrator rights" .

How to open notebook with administrator rights

3) Then in the notepad that opens, do the following:

  1. first click on the menu file / open ;
  2. further in the line "File name" (at the bottom of the window) enter the address of the hosts file - C: \ Windows \ System32 \ drivers \ etc \ hosts , and press the button open;
  3. a file should open in notepad. If this did not happen, then there are two options: either you entered the file address incorrectly, or it was blocked by a virus. Go to the second part of the article about restoring this file ...

Opening the hosts file

4) Now pay close attention to the lines in the file:

  1. if there are social sites in front of any IP-address. networks (for example), then these are probably malicious strings. Usually, they appear when installing adware (an example is shown in the screenshot below 👇). Just remove all such lines;
  2. some do not scroll to the end of this text file (but in vain!) - the fact is that sometimes a trick is used: some of the lines are filled with spaces, and as a result, the user, opening the file, thinks that everything is in order with him.

Suspicious line in hosts

In general, it is ideal to delete EVERYTHING that you have in the hosts file (especially if you have never dealt with it), and copy, for example, the normal text for this file (shown below) there.

👇 Sample file hosts, by default, after installing Windows (you can copy and replace your own completely)

# Copyright (c) 1993-2009 Microsoft Corp.

#

# This is a sample HOSTS file used by Microsoft TCP / IP for Windows.

#

# This file contains the mappings of IP addresses to host names. Each

# entry should be kept on an individual line. The IP address should

# be placed in the first column followed by the corresponding host name.

# The IP address and the host name should be separated by at least one

# space.

#

# Additionally, comments (such as these) may be inserted on individual

# lines or following the machine name denoted by a '#' symbol.

#

# For example:

#

# 102.54.94.97 rhino.acme.com # source server

# 38.25.63.10 x.acme.com # x client host

# localhost name resolution is handled within DNS itself.

# 127.0.0.1 localhost

# :: 1 localhost

127.0.0.1 localhost

After making all the edits with the file, do not forget to save it:

  1. or click on the menu file / save ;
  2. or a combination of buttons Ctrl + S.

Saving text

Method 2: manually launch notepad as administrator

  1. go to the system folder at: C: \ Windows \ system32
  2. find the file notepad.exe and click on it right mouse button ;
  3. in the context menu, select "Run with administrator rights" ;

    Run notepad as administrator

  4. if a message pops up "Allow this app to make changes on your device" —  allow !

    Allow

  5. further actions are similar to the first method (see above).

👉 Note

For these purposes, you can use absolutely any notebook, for example, very popular ones: notepad ++, bread, etc.

*

How to restore the original hosts file

In some cases, the real hosts file cannot be reached:

  • either cannot be opened (for example, blocked by a virus);
  • or it is hidden and invisible;
  • or there are just a few of them, and which one is real to understand for an inexperienced user is far from always within the power of ...

But there is one antivirus utility that can restore the hosts file quickly and easily. It's about a utility -AVZ.

👉 AVZ (and a number of other antiviruses) can be found in my selection.

After downloading and unzipping the utility - just run the executable file. Next open the menu "File / System Restore".

File / System Restore / AVZ

Then, in the list of restoring system settings, check the box "Clearing the hosts file" (as in the screenshot below 👇), and press the button "Perform marked operations" .

Note: please note that the AVZ utility offers to unlock and restore quite a few necessary system settings. In general, I recommend!

Clearing the hosts file

If everything went well, you should see a window about the successful completion of the restore operation (as in the example below).

Recovery completed

Recommend also check your computer for viruses using the same AVZ utility (moreover, do it even if you have an antivirus installed. You can learn a lot of interesting things about its effectiveness ... 👌).

👉 Note

You can also bring the system into working condition using recovery .

If there are backup points on the computer (and they are created by default in Windows 7/8), when Windows was stable, then you can roll back to them and restore the previous system operation. Including, by the way, the hosts file.

*

This completes my mission of the article!

If you could not restore the hosts file using the recommendations above, the last thing I recommend is to reinstall Windows.

Good luck!

👣

First publication: 03/04/2017

Correction: 01/15/2020

$config[zx-auto] not found$config[zx-overlay] not found