If you own a new MacBook or Mac, your machine will usually have system’s serial number as it’s hostname, diskname and computer name.
You can change the hostname via terminal using two different commands:
Option 1 – hostname
This option didn’t work for me as the hostname was getting reset after restart. Am currently on macOS Monterey 12.6.1 although osxdaily article suggests it works after Mavericks update.
sudo hostname -s new_hostname
Verify the change using this command:
hostname
> new_hostname
Note: Until restart this option seems to work
Option 2 – HostName, ComputerName, LocalHostName
sudo scutil --set HostName "raptordotin"
Using scutil command we can update ComputerName and LocalHostName as well.
sudo scutil --set ComputerName "raptor's Macbook Pro"
sudo scutil --set LocalHostName "raptordotin-local"
Verify the change using this command:
scutil --get HostName
> raptordotin
scutil --get ComputerName
> raptor's Macbook Pro
scutil --get LocalHostName
> raptordotin-local
Close and open the terminal again to see the change.
Disk Name
Finally it would be nice to rename your diskname as well.
Use this diskutil to rename disk name
diskutil rename / raptordotin-SSD
You can achieve the same using “Disk Utility” App as well.
Verify the change using UI:
- Open finder to verify computer name and disk name
- Open Settings -> Systems Preference -> Sharing to verify computer name and localhost name