Set the HostName and Computer Name via command line on OS X

Work recently acquired a few MacBook laptops to be used and shared by staff. Though the computing staff is not expected to have immense knowledge about OS X,  when things break down we are the first point of contact.

The last time I used a Mac machine extensively was around 2007. Then I switched to Debian and could never look back. Anyway, there must be lot of new things and I’ll try document or post snippets here as I learn new things.

The first one for today is to set the hostname and computer name from a command line.

$ export PC_NAME="macarena"
$ sudo scutil --set ComputerName "$PC_NAME" && \
$ sudo scutil --set HostName "$PC_NAME" && \
$ sudo scutil --set LocalHostName "$PC_NAME"

Reference: OS X – Set the HostName, Computer Name, and Bonjour Name via command line

Leave a Reply

Your email address will not be published. Required fields are marked *