Tools: I built a CLI to stop explaining what /etc/hosts is - Complete Guide

Tools: I built a CLI to stop explaining what /etc/hosts is - Complete Guide

What's wrong with existing tools

What hostfile does differently

Quick start

Install Last month, a PM asked me to point api.staging.local to a new IP. I spent 15 minutes explaining what /etc/hosts is. Then I did it for them anyway. This happens a lot. So I built hostfile — a CLI that turns hosts file management into copy-pasteable one-liners. Manual editing is risky. One wrong move and DNS resolution breaks. Non-technical users shouldn't be anywhere near vim /etc/hosts. GUI tools like SwitchHosts exist, but they're overkill when you just need someone to run one command. You can't paste a GUI into Slack. Other CLIs exist and work fine for developers who know what they're doing. But when you need a non-technical person to run one command without supervision, most fall apart. Managed block isolation. hostfile only touches entries between its own markers. Your hand-written entries are never modified: Enable/disable without deleting. Need to temporarily turn off an entry? hostfile disable api.local. Turn it back on with hostfile enable api.local. No re-typing IPs. JSON I/O and pipelines. Export your config as JSON, pipe it to another machine, or feed it into scripts: Automatic privilege escalation. hostfile handles sudo, doas, or gsudo on Windows automatically. Users never need to remember. Input validation. Bad JSON, invalid IPs, or garbage text gets rejected before touching your hosts file. Also available as .deb, .rpm, and Scoop. See the README for all options. This isn't a revolutionary tool. It solves one specific problem: making hosts file changes safe and accessible to anyone who can copy-paste a command. If that's a problem you have, give it a try. GitHub: vulcanshen/hostfile Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Command

Copy

# Your stuff — safe 127.0.0.1 localhost #### hostfile >>>>> 192.168.1.100 web.local api.local #### hostfile <<<<< # Your stuff — safe 127.0.0.1 localhost #### hostfile >>>>> 192.168.1.100 web.local api.local #### hostfile <<<<< # Your stuff — safe 127.0.0.1 localhost #### hostfile >>>>> 192.168.1.100 web.local api.local #### hostfile <<<<< # Export hostfile show --json # {"192.168.1.100": ["web.local", "api.local"]} # Import via pipeline echo '{"10.0.0.1":["db.local"]}' | hostfile merge - # Sync between machines hostfile show --json | ssh prod hostfile apply - # Export hostfile show --json # {"192.168.1.100": ["web.local", "api.local"]} # Import via pipeline echo '{"10.0.0.1":["db.local"]}' | hostfile merge - # Sync between machines hostfile show --json | ssh prod hostfile apply - # Export hostfile show --json # {"192.168.1.100": ["web.local", "api.local"]} # Import via pipeline echo '{"10.0.0.1":["db.local"]}' | hostfile merge - # Sync between machines hostfile show --json | ssh prod hostfile apply - # Install (macOS/Linux) -weight: 500;">curl -fsSL https://raw.githubusercontent.com/vulcanshen/hostfile/main/-weight: 500;">install.sh | sh # Add entries hostfile add 192.168.1.100 web.local api.local # Save a snapshot before making changes hostfile save before-migration # Roll back if needed hostfile load before-migration # Done with this setup hostfile clean # Install (macOS/Linux) -weight: 500;">curl -fsSL https://raw.githubusercontent.com/vulcanshen/hostfile/main/-weight: 500;">install.sh | sh # Add entries hostfile add 192.168.1.100 web.local api.local # Save a snapshot before making changes hostfile save before-migration # Roll back if needed hostfile load before-migration # Done with this setup hostfile clean # Install (macOS/Linux) -weight: 500;">curl -fsSL https://raw.githubusercontent.com/vulcanshen/hostfile/main/-weight: 500;">install.sh | sh # Add entries hostfile add 192.168.1.100 web.local api.local # Save a snapshot before making changes hostfile save before-migration # Roll back if needed hostfile load before-migration # Done with this setup hostfile clean # macOS / Linux -weight: 500;">brew -weight: 500;">install vulcanshen/tap/hostfile # Windows irm https://raw.githubusercontent.com/vulcanshen/hostfile/main/-weight: 500;">install.ps1 | iex # macOS / Linux -weight: 500;">brew -weight: 500;">install vulcanshen/tap/hostfile # Windows irm https://raw.githubusercontent.com/vulcanshen/hostfile/main/-weight: 500;">install.ps1 | iex # macOS / Linux -weight: 500;">brew -weight: 500;">install vulcanshen/tap/hostfile # Windows irm https://raw.githubusercontent.com/vulcanshen/hostfile/main/-weight: 500;">install.ps1 | iex