How to Use the macOS scutil Command to Change Your Computer Name

The Confusion of Mac Naming

When you buy a brand new Mac, macOS automatically assigns it a generic name during the initial setup process, usually something like “John’s MacBook Pro.” This name is broadcast constantly over your local network. It is the name that appears when someone tries to AirDrop you a file, when your router assigns an IP address, and when you try to connect to the computer remotely via SSH.

If you have three different MacBook Pros in a single household, having them all named “MacBook Pro” creates massive confusion on the network. While you can change the basic AirDrop name via the graphical System Settings (General > About), that interface does not actually change the underlying, low-level UNIX hostnames that the terminal and networking protocols rely on.

To truly change the identity of your Mac across all three networking layers simultaneously, you must use the scutil (System Configuration Utility) command.

Step 1: Open the Terminal

Because you are changing system-wide network configurations, you will need to run these commands with administrative privileges.

  1. Press Command + Space to open Spotlight Search.
  2. Type Terminal and press Enter.

Step 2: Understanding the Three Names

macOS actually maintains three completely separate names for your computer.

  • ComputerName: The friendly, human-readable name that appears in the AirDrop menu and Finder sidebars.
  • LocalHostName: The Bonjour network name (usually ending in .local) used by Apple services on your local Wi-Fi. It cannot contain spaces.
  • HostName: The strict UNIX hostname used by the terminal and remote SSH connections.

To see what your Mac is currently named across all three categories, run these three commands one by one:

scutil --get ComputerName
scutil --get LocalHostName
scutil --get HostName

If you have never changed these via the terminal, you might notice that the HostName comes back completely blank, or says something unhelpful like localhost.

Step 3: Changing the Names

To establish a clean, consistent identity on your network, you should set all three names to match. For this example, we will rename the Mac to “Studio-Mac”.

Because you are modifying the core system configuration, you must prefix these commands with sudo and you will be prompted to enter your Mac login password.

First, change the friendly AirDrop name (this one is allowed to have spaces if you prefer, but avoiding them is cleaner):

sudo scutil --set ComputerName "Studio-Mac"

Second, change the Bonjour local network name (this absolutely cannot contain spaces or special characters):

sudo scutil --set LocalHostName "Studio-Mac"

Finally, change the strict UNIX hostname so your terminal prompt looks correct:

sudo scutil --set HostName "Studio-Mac"

Step 4: Flushing the DNS Cache

While the names have been instantly changed in the system configuration, your Mac’s active network cache might still be broadcasting the old names to your router.

To force the Mac to immediately broadcast its brand new identity to the rest of the network, you should flush the mDNS (Multicast DNS) cache.

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Close your terminal window and open a brand new one. You will instantly see your shiny new hostname (e.g., user@Studio-Mac ~ %) sitting proudly at the command prompt.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.