Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

share|improve this question
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 >> 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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .