macOS: Update the computer name on macOS with a command
To update the computer name on macOS. Normally, we go to the sharing menu. We found that sometimes after changing the computer name. But on the router (Mikrotik) logs still show the old computer name (NetBios name). So, this will show how to get and update the computer name with command on macOS.
Here 3 ways to check the computer name on macOS
1. Check the computer name on the sharing menu: System Preferences > Sharing > Computer name.
2. Check computer name on Network: Goto Network Preferences... > Advanced > WINS > NetBIOS Name.
3. Check the computer name on Terminal:
- Command to check LocalHostName
scutil --get LocalHostName
- Command to check ComputerName
scutil --get ComputerName
- Command to set the ComputerName
sudo scutil --set ComputerName "computer name"

After updating the computer name, try restarting and check the computer name again.