Fill these in once
- Set all three names macOS usesNeeds sudo
sudo scutil --set ComputerName "my-laptop" sudo scutil --set LocalHostName "my-laptop" sudo scutil --set HostName "my-laptop"
Check it worked
- Check the new name
scutil --get ComputerName && hostname
- Set the new nameNeeds sudo
sudo hostnamectl set-hostname my-laptop - Update the hosts file to matchNeeds sudo
sudo sed -i "s/^127.0.1.1.*/127.0.1.1\tmy-laptop/" /etc/hostsStops "unable to resolve host" warnings after the rename.
Check it worked
- Check the new name
hostnamectl
- Rename and restartRun as administrator
Rename-Computer -NewName "my-laptop" -RestartYour PC restarts straight away. Save your work first.
Check it worked
- Check the new name
hostname