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>"

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap