View and manage all three macOS hostname types — HostName, LocalHostName, and ComputerName.
macOS maintains three separate hostname values, each used in different contexts:
| Type | Used by |
|---|---|
| HostName | Terminal prompt, SSH |
| LocalHostName | Bonjour, AirDrop discovery |
| ComputerName | Finder sidebar, file sharing |
Running hostname without arguments shows all three. Passing a new name sets all three at once via scutil and flushes the DNS cache.
brew install ansilithic/tap/hostnameOr build from source (requires Xcode and macOS 14+):
make build && make installUSAGE: hostname [<new-hostname>]
ARGUMENTS:
<new-hostname> New hostname to set (omit to show current)
OPTIONS:
--version Show the version.
-h, --help Show help information.
# Show current hostnames
hostname
# Set all three hostnames at once (requires sudo)
hostname MacBookMIT
