Skip to content

Instantly share code, notes, and snippets.

@lopugit
Last active February 11, 2022 20:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lopugit/21f5b55e0eb656c1d4dccccf89ec8310 to your computer and use it in GitHub Desktop.
Save lopugit/21f5b55e0eb656c1d4dccccf89ec8310 to your computer and use it in GitHub Desktop.
Setting the Mac hostname or computer name from the terminal
Summary
This article provides instructions on setting the hostname of a Mac OS X workstation from the terminal.
This can be useful when configuring your workstation remotely through ssh, or when you need to change the fully qualified hostname of the workstation (which can't be done from the UI).
Note: The following procedure is for informational purposes only and is not an Autodesk certified or supported workflow. Should issues arise with this procedure, they will not be addressed by Autodesk Customer Support.
Procedure
Perform the following tasks to change the workstation hostname using the scutil command.
Open a terminal.
Type the following command to change the primary hostname of your Mac:
This is your fully qualified hostname, for example myMac.domain.com
sudo scutil --set HostName <new host name>
Type the following command to change the Bonjour hostname of your Mac:
This is the name usable on the local network, for example myMac.local.
sudo scutil --set LocalHostName <new host name>
Optional: If you also want to change the computer name, type the following command:
This is the user-friendly computer name you see in Finder, for example myMac.
sudo scutil --set ComputerName <new name>
Flush the DNS cache by typing:
dscacheutil -flushcache
Restart your Mac.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment