How to Change Mac Computer and Localhost Name using Terminal

If you want to change the Computer Name of your Mac (Macbook/iMac/Mac Studio) then you can make use of scutil command using the --set option.


Syntax:
% scutil --set ComputerName "<name>"

Example:
% scutil --set ComputerName "Sam's Macbook Pro"
scutil is trying to modify the system network configuration

You will get a prompt - "scutil is trying to modify the system network configuration. Touch ID or enter your password to allow this."


Note: There are 3 names on Mac that you should be aware of,

  1. Computer Name: The user-friendly name displayed on the Sharing preference pane and used for identifying your Mac on a local network.
  2. Localhost Name: The name that is displayed at the bottom of the Sharing Settings window
  3. Host Name: The name used to identify the computer on a network.

You can change all of them using scutil,

sudo scutil --set ComputerName "<your-new-name>"
sudo scutil --set LocalHostName "<your-new-name>"
sudo scutil --set HostName "<your-new-name>"

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!