Read and Set the Mac's Names with scutil --get/--set
macOS keeps three separate name values; scutil is the only tool that reads and sets all of them.
Run `scutil --get ComputerName` (and LocalHostName, HostName) to read the names; set them with `sudo scutil --set <name> <value>`.
01Command
Command
$ scutil --get ComputerName
scutil --get LocalHostName
scutil --get HostName
# Set one:
sudo scutil --set HostName mymac.example.com02What it does
ComputerName is the friendly name shown in AirDrop and Screen Sharing, LocalHostName is the Bonjour name (myname.local), and HostName is the shell's prompt hostname, which is often unset until you define it. A Mac can show `unknown-xx-xx-xx-xx` or a stale `.local` name precisely because these three diverged. Setting them with scutil takes effect in new shells immediately, while `sudo hostname x` does not survive reboot.
03Risk
!Warning: Changing LocalHostName invalidates the old .local name until Bonjour re-registers.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- scutil — macOS Command ReferenceEvidence: Documents --get/--set for ComputerName, LocalHostName and HostName.
Last verified: 2026-09-17 · Category: Network