Hosts database manager for *NIX systems

hosts(1) - hosts database manager

A command line tool for managing the hosts database on *NIX systems. Requires bash >= 4.2.

Often it makes sense when developing a web application to use the host name for development so you create a host file mapping to point the domain name to the local loopback address:

Then you put the application live so you comment out the entry:


But you still need to switch between the local development version and the live version regularly which is when editing the hosts file manually becomes tedious.

Enter the hosts(1) tool which lets you manage the host file as a set of blocks which can be easily switched on or off.

The man page for hosts(1) is available via the command hosts help or you can view the online version if you prefer.

By default the blocks and other files are stored in $hosts_storage with this directory layout:

├── backup
│   └── hosts
├── history
│   └── hosts.1
├── loopback
│   └── hosts
├── blocks
    └── example.on
curl -# | bash

Will install the repositories into /usr/local/lib and create a symlink to the hosts executable in /usr/local/bin.

Install with npm:

npm install -g hostfile
  1. sudo is only required if you do not have permission to write to the hosts file.
  2. curl is only required if you wish to interact with the remote database to share blocks and/or profiles.

You can verify an installation with:

command -v hosts > /dev/null \
    && hosts --version

If you used the quick install you can uninstall with the provided uninstall program located in /usr/local/bin:


If you installed with npm then use the uninstall or rm command:

npm rm hostfile

Verify you have bash >= 4.2 using bash --version. If you have an older version, you should update.

Ensure you have md5(1) and curl(1), clone the repository and install the strike(7) dependency by running npm install.

Use the bake symlink to run the test suite:

./bake test

You must have an active internet connection for all tests to pass as some tests query the database.

Everything is MIT. Read the license if you feel inclined.