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 <command> [options] [arguments]

Common Commands:
hostess add <IP_ADDRESS> <HOSTNAME> [HOSTNAME...]
hostess rm <HOSTNAME> [HOSTNAME...]
hostess ls
hostess on <HOSTNAME> [HOSTNAME...]
hostess off <HOSTNAME> [HOSTNAME...]

PARAMETERS

add <IP_ADDRESS> <HOSTNAME> [HOSTNAME...]
    Adds a new entry mapping IP_ADDRESS to one or more HOSTNAMEs. If the IP exists, new hostnames are appended to that line.

rm <HOSTNAME> [HOSTNAME...]
    Removes one or more specific HOSTNAME entries from the hosts file. If a hostname is the last one for an IP, the entire line is removed.

ls
    Lists all entries in the hosts file, indicating which are active and which are disabled (commented out).

on <HOSTNAME> [HOSTNAME...]
    Enables (uncomments) one or more previously disabled HOSTNAME entries, making them active for name resolution.

off <HOSTNAME> [HOSTNAME...]
    Disables (comments out) one or more specific HOSTNAME entries, effectively making them inactive without deleting them from the file.

-h, --help
    Displays the help message and available commands for hostess or a specific subcommand.

-v, --version
    Prints the hostess utility's version information.

DESCRIPTION

The hostess command is a powerful and convenient utility designed for streamlined management of the /etc/hosts file on Unix-like operating systems. It simplifies the common tasks associated with mapping IP addresses to hostnames, traditionally performed by manually editing the plain-text file. hostess provides subcommands to add, remove, list, enable, and disable entries, making it an ideal tool for developers, system administrators, or anyone who frequently modifies their local DNS mappings for development environments, ad blocking, or testing.

It handles the necessary permissions (often requiring sudo internally) and ensures the integrity of the hosts file, reducing the risk of syntax errors. By abstracting the manual editing process, hostess enhances productivity and reduces potential mistakes, offering a more reliable and scriptable way to manage local DNS resolution.

CAVEATS

hostess is not a standard Unix command and needs to be installed separately, typically via `go get` or by downloading pre-compiled binaries. As it modifies the system-wide /etc/hosts file, it often requires superuser privileges (sudo) to execute its commands successfully. Care should be taken when making changes to avoid disrupting network resolution.

PERMISSIONS

Commands that modify the /etc/hosts file (add, rm, on, off) typically require root privileges. hostess is often designed to prompt for sudo automatically if necessary, or the user may need to invoke it with sudo hostess ....

IDEMPOTENCY

Many hostess operations are idempotent; for example, attempting to add an existing entry or remove a non-existent one generally won't cause errors or unintended side effects, making it suitable for scripting.

HISTORY

The hostess utility was primarily developed by Christian Bednarski and is written in Go. Its development aimed to provide a more ergonomic and reliable way to manage /etc/hosts entries programmatically or from the command line, avoiding the common pitfalls of manual file editing. It gained popularity among developers and sysadmins looking for a robust tool for local DNS manipulation, offering a structured approach to a traditionally manual process.

SEE ALSO

hosts(5), hostname(1), dig(1), nslookup(1)

Copied to clipboard