hostctl

Manage /etc/hosts with profiles

TLDR

List all profiles and their entries
$ hostctl list
Add entries to a profile
$ hostctl add [profile_name] [ip] [hostname]
Enable a profile
$ hostctl enable [profile_name]
Disable a profile
$ hostctl disable [profile_name]
Remove a profile
$ hostctl remove [profile_name]
Import a profile from a file
$ hostctl set [profile_name] -from [path/to/file]
Create a backup of the hosts file
$ hostctl backup
Sync profile with Docker Compose containers
$ hostctl sync dockercompose -f [docker-compose.yml] -p [profile_name]

SYNOPSIS

hostctl command [options] [arguments]

DESCRIPTION

hostctl is a CLI tool for managing your /etc/hosts file using profiles. You can have multiple profiles, enable or disable exactly what you need, and switch between different host configurations with simple commands. It automatically detects your OS and uses the correct hosts file location.Profiles allow grouping host entries for different environments (development, staging, production) and toggling them on or off without manual file editing. It also supports syncing profiles with Docker and Docker Compose containers.

PARAMETERS

list

Show a detailed list of profiles and entries
add profile ip hostname
Add an entry to a profile
enable profile
Enable a profile
disable profile
Disable a profile
remove profile
Remove a profile entirely
set profile
Replace content of a profile
backup
Create a backup of the hosts file
sync
Sync with Docker or Docker Compose

INSTALL

nix profile install nixpkgs#hostctl

CAVEATS

Modifying the hosts file requires root/administrator privileges. Incorrect entries can break local DNS resolution. Always use the backup command before making large changes.

HISTORY

hostctl was created by guumaster and is written in Go. It was designed to replace manual editing of the hosts file with a structured, profile-based approach that integrates with modern development workflows.

SEE ALSO