Starting with Big Sur, I have trouble setting the hostname for my machine. If I go to Settings > Sharing and set the computer name to <myhostname>, it will set my hostname to something like DESKTOP-66SJRDC. I have no idea where that value comes from.
Then I set the hostname manually in Terminal via
sudo hostname <myhostname>
and it seems to use the correct hostname now. However once I change the Computer Name again in Sharing it falls back to some random value and I have to set it in terminal again.
I remember just needing to set the Computer Name in earlier macOS versions and not messing about with hostname. Did something change in Big Sur?
Where does the random value come from?
It started with the update to Big Sur
– peshkira Sep 29 '21 at 07:31hostnamecommand, the name assigned to my computer by the network admin shows. I guess the network/DHCP-assigned name, when one exists, must take precedence over the locally-set hostname. – leanne Dec 02 '23 at 05:10myname@networkname $instead ofmyname@computername $, with computername being what I set in Sharing. – leanne Feb 28 '24 at 22:25computer_name=${"$(scutil --get ComputerName)"//\%/%%}followed byPS1='%n@$computer_name...'placed in my.zshrcfile. – leanne Feb 28 '24 at 22:36