How to open the hosts file, why is this needed, and what parameters can be changed in it?

Apparently, many users very often encounter the fact that sometimes when a computer is infected with a virus, when installing hacked or illegal software, it is recommended to make some changes to the hosts file. What is this system component, ordinary users usually do not even guess, not to mention the knowledge of how to open the hosts file and what changes it can (and whether at all) can be made. That is why an understanding of its functional purpose is worth dwelling in more detail.

What is a hosts file, and what information is stored in it?

For now, let’s leave aside the questions related to how to open the hosts file and see what kind of object it is and why it is needed in the system.

Standard hosts file content

If you give the simplest explanation, you can immediately note the fact that this file in its essence and content is the most ordinary text document, although it does not have an extension. Yes Yes exactly! Even if the Explorer displays the extensions for all registered file types, it will not be indicated for this object. And this is done for a reason. The fact is that the information stored in this file is intended for mapping domain names with the IP addresses of requested Internet resources.

How the hosts file is used

Roughly speaking, when you enter the site address in a browser, the system first accesses this file, and only then does validation take place at the DNS server level. In general, this component can be called to some extent a kind of semblance of a local DNS server built into Windows or into any other system. As for the information that is written in the file, the main content is by and large just a descriptive part, and the main interest is the commands that are indicated for the local host, which in all cases has the address 127.0.0.1. What does this mean? This means that by changing the parameters specified in this file, you can either redirect to other resources, or even restrict access to some sites, blocking both the system and programs that are trying to access them to connect. Thus, its priority is higher than even a DNS server.

Why do viruses most often attack this file?

From the point of view of security of any computer system with Internet access, this component, in connection with its priority parameters, is almost one of the most basic goals against which various types of virus threats are attacked. Why is that? Yes, only because after changing some entries, the threat can gain control not only over the connection, but also redirect the user to various kinds of questionable, advertising or fake resources on the Internet, for example, with the aim of stealing personal data. And the presence of advertising is far from the worst consequences that may be.

Suppose that the virus registered a redirect to a fake banking page in the hosts file. The user seems to enter the legal (official) address of the resource, but then, without realizing anything, he gets to a completely different page that may look like the original one. Then he enters his usernames and passwords for access to personal banking operations, and as a result, say, all funds disappear from his card. That is why access to the hosts file for editing by default in the system is blocked, even if you are an administrator three times (for Windows 7 and above). But how to open the hosts file if it is really necessary? There are several ways to do this, which we’ll talk about a bit later, but for now let's see where this object is located.

Where is the hosts file on Windows?

In all Windows-systems to find this object is not particularly difficult. For convenience, we will consider modifications to the system 7 and above. It is enough to go into the main directory of the system in the "Explorer", go to the System32 directory, open the drivers folder and enter the etc. directory

Hosts file location

If you need to do something simpler, you can specify a search through the Run menu using the% systemroot% or% WinDir% attributes, after which, through the left slash, all folders that are navigated are successively indicated.

How to open hosts file in Windows 7 or any other OS of this family for viewing?

So, with the contents and location of the file a little understood. Now, based on the fact that this is really a text document, let's see how to open the hosts file using Notepad or any other text editor. If it is only a matter of viewing, and not editing the contents, you can open it either in an already running program, selecting all files from the list of types of objects to be opened, or open it using Explorer, where the option β€œOpen with help ... ”, after which the standard Notepad application or any other similar application of this class is indicated.

Opening the hosts file for viewing

Please note that despite the fact that this object belongs to text files, you cannot open it in editors such as Word, since even the etc folder will not be displayed in the list. But if you use the "Open with ..." item, you can perform such an operation without problems. But in either case, saving the changes made will not work.

How to open hosts file as administrator?

But sometimes you really need to edit the file. But how to open the hosts file with Notepad so that the changes can be saved? In this case, the program itself for processing text content must be run exclusively on behalf of the administrator. For Notepad in Windows 7, you can do this through the Run console by typing the notepad command and ticking off the start point with admin rights. If this item is missing, you can run the Notepad.exe file as an administrator in the "Explorer" (it is located in the root directory of the Windows system).

Running Notepad as administrator

Another technique is to create a new task in the "Task Manager", and in the console enter the above command with a start mark on behalf of the administrator. After making changes, you can save the hosts file with the standard quick combination Ctrl + S.

How and what changes can be made to the contents of the hosts file?

As for the changes, they basically boil down to blocking some site by entering its address after the last two lines using the pound sign and the local host address.

Lockable resources in hosts file

So, for example, if some program with a hacked license (or offline registration using a key generator) constantly accesses the official website of the developer, there is nothing easier than setting a connection block. In this case, the application will β€œthink” that there is no Internet connection, and will not check the license.

Finally, speaking about how to open the hosts file, one should not forget that some portable anti-virus programs make changes to the contents of this object on their own when they detect threats. Therefore, deleting entries created under the auspices of such security applications is not recommended. And indeed, without the need for this object is better not to touch at all.

Source: https://habr.com/ru/post/C38152/


All Articles