LinuxCommandLibrary

hostess

Manage hostname resolution using local files

TLDR

List domains, target IP addresses, and on/off status

$ hostess list
copy

Add a domain pointing to your machine to your hosts file
$ hostess add [local.example.com] [127.0.0.1]
copy

Remove a domain from your hosts file
$ hostess del [local.example.com]
copy

Disable a domain (but don't remove it)
$ hostess off [local.example.com]
copy

SYNOPSIS

hostess add <hostname> <ip> [<alias> ...]
hostess del <hostname> [--alias]
hostess dump
hostess flush

PARAMETERS

add
    Adds hostname/IP entry with optional aliases to /etc/hosts

del
    Deletes specified hostname from /etc/hosts

--alias
    With del: remove all aliases for the hostname too

dump
    Prints all non-comment entries from /etc/hosts

flush
    Flushes local DNS cache (uses systemd-resolve if available)

<hostname>
    Required hostname argument for add/del

<ip>
    IP address for new entry (required with add)

<alias>
    Optional alias hostnames for add

DESCRIPTION

Hostess is a lightweight command-line utility for managing entries in the /etc/hosts file on Linux and other Unix-like systems.

It offers simple subcommands to add hostnames with IP addresses and aliases, remove entries, dump the current hosts file contents, and flush the local DNS cache. This tool is ideal for developers who frequently need to map local domains (e.g., for web servers), block unwanted sites by redirecting to 0.0.0.0, or handle temporary network configurations without manually editing the hosts file, which can be error-prone.

Hostess parses the file intelligently, preserves comments and formatting, and supports multiple aliases per entry. It's written in Go, compiles to a single binary, and works cross-platform, making it easy to use in scripts or CI/CD pipelines.

Unlike built-in tools, it provides a user-friendly interface over direct file manipulation, reducing risks like syntax errors that could disrupt networking.

CAVEATS

Requires sudo for add, del, flush as they modify system files or cache.
Not installed by default; third-party tool. Flush ineffective without systemd-resolve.

INSTALLATION

Linux: go install github.com/chrissimpkins/hostess/cmd/hostess@latest (requires Go).
Or download prebuilt binary from releases.

EXAMPLES

Add local domain: sudo hostess add myapp.local 127.0.0.1 api.myapp.local
Block site: sudo hostess add badsite.com 0.0.0.0
List: hostess dump
Remove: sudo hostess del myapp.local --alias

HISTORY

Created by Chris Simpkins; GitHub repo launched September 2016. Written in Go for portability across Linux, macOS, Windows. Actively maintained with recent updates for modern resolvers.

SEE ALSO

hosts(5), systemd-resolve(8), getent(1)

Copied to clipboard