How to edit and save Windows Vista and Windows 7 hosts file

By default, hosts file in your c:\windows\system32\drivers\etc directory is set to be Hidden, System, Read Only. These attributes do now allow you regular Windows user from editing its contents. Here are the shortest steps to edit hosts file permissions.

  1. Go to Start, All Programs, Accessories
  2. Right-click on Command Prompt, and click on Run as administrator
  3. If you get a Windows Security pop-up, click Allow
  4. In the Command Prompt window type in dir, and hit the Enter key
  5. You should see a list of several files, hosts will not be one of them
  6. In the Command Prompt window typ in cd\
  7. In the Command Prompt window type in cd c:\windows\system32\drivers\etc, and hit the Enter key
  8. In the Command Prompt window type in attrib -r -h -s hosts, and hit the Enter key
  9. In the Command Prompt window type in dir, and hit the Enter key
  10. You should now see hosts file listed, if you do, the permissions have been changed successfully, and you can browse and edit the hosts file in notepad
  11. Go to Start, All Programs, Accessories
  12. Right-click on Notepad, and click on Run as administrator
  13. You can change the permissions back by typing in attrib +r +h +s hosts, in the Command Prompt window

Sometimes malware may change ownership of your hosts file and the above steps will not work.  In this case you will have to boot to Safe Mode, and force a change of ownership of the hosts file.

  1. Make sure to view system and hidden files
  2. Boot to Safe Mode
  3. Right-click on the etc folder, and go to properties
  4. Click the Advanced tab
  5. Click the Owner tab
  6. Click the Edit button, and check ON “Replace owner on subcontainers and objects” box
  7. Select your user, or Administrators group
  8. Click “OK” three times to get out of folder properties
Folder owner

Folder owner

Folder Owner details

Folder Owner details

Leave a Reply

Your email address will not be published. Required fields are marked *