macOS maintains three distinct hostname fields, each serving a different audience. ComputerName is the friendly display name in Finder, AirDrop, and the sharing pane (allows spaces and capitalization). LocalHostName is the Bonjour/mDNS name on the LAN, served as <name>.local and auto-normalized to lowercase, hyphenated, no dots, max 63 characters. HostName is the BSD hostname returned by hostname(1) and used by terminal-context tools: SSH banners, shell scripts, syslog. All three are managed by configd and read or written via scutil. A “rename” that updates only one is incomplete; the others continue to advertise the old name to whichever subsystem reads them.

The split matters because tools disagree on which field to read. Set only LocalHostName (the field exposed in System Settings) and the terminal prompt, SSH banner, and shell scripts still report the stale value. The default fallback when HostName is unset is often literally Mac or whatever DHCP option 12 supplied (RFC 2132 §3.14).

FieldGUI surfaceCLI to setCLI to read
ComputerNameSettings → General → Sharing → “Name”sudo scutil --set ComputerName <name>scutil --get ComputerName
LocalHostNameSharing → edit pencil → “Local hostname”sudo scutil --set LocalHostName <name>scutil --get LocalHostName
HostNameNone (CLI only)sudo scutil --set HostName <name>scutil --get HostName

DHCP-supplied hostnames are gated by Settings → General → Sharing → edit pencil → “Use dynamic global hostname”. Toggle ON: macOS accepts network-supplied hostnames into HostName, potentially overriding what was set via scutil (joining a new network can silently rename the machine). Toggle OFF: HostName is yours alone, only an explicit scutil --set HostName changes it. For a deterministic hostname across networks: turn the toggle off, then sudo scutil --set HostName <name>.

Verification:

echo "HostName:      $(scutil --get HostName)"
echo "LocalHostName: $(scutil --get LocalHostName)"
echo "ComputerName:  $(scutil --get ComputerName)"
echo "hostname(1):   $(hostname)"

A complete rename touches all three fields; there is no single command. LocalHostName is the only field with strict normalization, so pick a name that survives it. ComputerName is the only field that carries spaces or mixed case, so treat it as a display label, not an identifier. Linux differs meaningfully: a single hostname managed via hostnamectl, with much weaker subsystem fragmentation. The policy of what name to choose lives in Hostname Naming Convention; this note covers how to set it on Darwin.