Title: How to restore the hosts file after deletion
Abstract: The hosts file is a very important file in the operating system and is used to map domain names to IP addresses. If you accidentally delete the hosts file, you may be unable to access certain websites or have other network problems. This article will introduce how to recover accidentally deleted hosts file in Windows and Mac operating systems.
Text:
1. Restoring the hosts file in the Windows operating system
The hosts file in the Windows operating system is located in the driversetc folder under the system folder. The specific path is C:WindowsSystem32driversetc. Follow the steps below to recover accidentally deleted hosts file.
1. Start Windows Explorer and navigate to the C:WindowsSystem32driversetc folder.
2. Right-click a blank area in the folder, select "New" > "Text Document", and name it hosts.
3. Double-click the newly created hosts file and select "Notepad" or other text editor to open it.
4. Paste the following content in the hosts file:
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
Note: The above content is the basic content in the default hosts file. If you have customized the hosts file before, you need to copy and paste the backup contents line by line into the newly created hosts file to ensure that the previously performed domain name mapping still takes effect.
5. Save and close the hosts file.
6. Restart the computer.
2. Restore hosts file in Mac operating system
The hosts file in Mac operating system is located in the /private/etc folder and can be restored according to the following steps.
1. Open the "Terminal" application. You can find it in the Applications folder, or search for and open it using Spotlight (press Command Space and then type Terminal).
2. Enter the following command in the terminal window and press Enter:
sudo nano /private/etc/hosts
3. Enter your administrator password and press Press the Enter key to confirm.
4. In the editor that opens, copy and paste the following content into the hosts file:
Host Database
# # localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
5. Press "Control X" to exit the editor, then press the "Y" key to save the changes, and finally press the Enter key to confirm the saved file name.
Summary:
The above is the detailed content of How to restore the deleted hosts file. For more information, please follow other related articles on the PHP Chinese website!