Setting the Hostname on macOS Revision as of Monday, 19 December 2022 at 18:40 UTC
For my work laptop on macOS 12.6 Monterey. Assume the hostname is dobby.ether
.
A simple sudo hostname dobby
did not persist the hostname across sessions or reboots; it kept resetting to MacBook-Pro
. I don’t know if this was some policy pushed out or because of weirdness with macOS itself.
HostConfig
# This did not exist
sudo vim /etc/hostconfig
# I added this line
HOSTNAME=dobby.ether
This did not work. YMMV.
scutil
scutil --set LocalHostName rheya
scutil --set HostName rheya.ether
Enter the password when asked. This should work.