Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I routinely need to add / remove / update hosts on a Windows 7 machine to add links to staging / test servers.

On Mac I can use ghosts with the syntax

ghost add staging-server.local 67.207.136.164

Is there a similar command I can use on Windows to achieve the same functionality?

share|improve this question
add comment

2 Answers

up vote 6 down vote accepted

There are two (well, three really) ways you can do it.

GUI (using notepad, or whatever editor)

Right click on your favourite editor, ensure you Run as administrator (escalate them privileges), goto c:\windows\system32\drivers\etc\HOSTS and then add, edit to your heart's content.

Running without privileges will get you an Access Denied error when you try to save, which is thanks to some Windows security they put up some time ago.

cmd (surprisingly, it has a use sometimes)

Type cmd into your startbar, right click and Run as Administrator, then you can just type echo ipaddress site.com >> c:\windows\system32\drivers\etc\HOSTS

Alternate GUI (What I would advocate)

Hostsman is a nice little program which gives you a GUI you can manage your HOSTS on. I don't know about any other programs, but this seems to work perfectly find for what is needed.

share|improve this answer
    
Hostman looks good, thanks! –  Tom Feb 29 '12 at 11:42
add comment

As mentioned, the the file you need to edit must be edited as Administrator, and the path is c:\windows\system32\drivers\etc\hosts. It can be edited with Notepad or vim or whatever you prefer.

Hosts File Editor is a nice open source and free GUI for managing the hosts file.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.