Hola! the other day I had a need to change a MacOS hostname using the Terminal. I did not have access to a GUI and had to do this remotely. Chagning the hostname using MacOS Terminal is quite simple and is my favorite method. This is why I decided to document this little how to.
To open your Terminal go to Applications/Utilities or just do a Spotlight Search and type Terminal.
Once in your Terminal type:
scutil --set ComputerName "name"
Replace “name” with the computer name you wish to assign and press return. Next, you need to set your local network to Bounjour-based services by typing this command:
scutil --set LocalHostName "name"
Again, replace “name” with the same name you used before.
One last one is to set the name when connecting via SSH and the name shown on your Terminal. Simple type:
scutil --set HostName "name"
Once again, replace “name” with the same name you used before. If you get an authentication window enter your password. This account must have admin rights to make the changes.
After you set all of the above to your desired computer name/MacOS hostname you can verify your MacOS hostname by typing this command:
scutil --get HostName
You should see the new MacOS hostname/computer name displayed on your terminal. Thank you and if you like to support me you can get my Code with Coffee T-Shirt design. I make all designs based in NYC.