Prabhakar Kasi iOS Developer, Front End Developer

How to Change Your Mac Hostname, ComputerName, LocalHostName & DiskName via Terminal

1 min read

If you own a MacBook or iMac, you may have noticed that the default machine names often reflect a serial number or generic “MacBook‑Pro of “user”” label. Changing these identifiers helps make your system easier to recognize on the network, in AirDrop, Terminal, or when you manage multiple machines.

This guide covers the differences between HostName, ComputerName, LocalHostName, and DiskName, shows you the Terminal commands to adjust each, and offers troubleshooting tips to make sure your changes stick.



🔍 Understanding the Name Fields

Name TypeWhere It AppearsNotes
HostNameThe network name your Mac uses on other devices (e.g., via SSH or Terminal)Often uses DNS‑style naming; appears when you run hostname in Terminal.
ComputerNameThe name shown in the Sharing panel, AirDrop, Finder sidebar, etc.More user‑friendly, plain text.
LocalHostNameThe Bonjour (local network) name, used by services like AirDrop and Home Sharing.Usually lower‑case, no spaces (converted to e.g., macbook‑pro‑local).
DiskNameThe volume name of your startup disk (e.g., “Macintosh HD”)Changing this affects how the disk appears in Finder, Terminal, and when mounted by other systems.


By default, macOS may set all of these to the same value (for example: John’s MacBook Pro). However, they each serve different roles — and you may want to customize them separately.



🛠 How to Change Name via Terminal

Prerequisite: Open Terminal (Applications → Utilities → Terminal). Many of these commands require sudo permissions, so you will be asked for your administrator password.

MacBook Terminal HostName

You can change the hostname via terminal using two different commands:

1. Option 1 – hostname

This option didn’t work for me as the hostname was getting reset after restart. Am currently on macOS Monterey 12.6.1 although osxdaily article suggests it works after Mavericks update.

sudo hostname -s new_hostname

Verify the change using this command:

hostname
> new_hostname

Note: Until restart this option seems to work

2. Option 2 – HostName, ComputerName, LocalHostName

sudo scutil --set HostName "raptordotin"

Using scutil command we can update ComputerName and LocalHostName as well.

sudo scutil --set ComputerName "raptor's Macbook Pro"
sudo scutil --set LocalHostName "raptordotin-local"

Verify the change using this command:

scutil --get HostName
> raptordotin
scutil --get ComputerName
> raptor's Macbook Pro
scutil --get LocalHostName
> raptordotin-local

Close and open the terminal again to see the change.

Verifying HostName, ComputerName, LocalHostName changes in command line

3. Disk Name

Finally it would be nice to rename your diskname as well.

Use this diskutil to rename disk name

diskutil rename / raptordotin-SSD

You can achieve the same using “Disk Utility” App as well.

Verify the change using UI:

  1. Open finder to verify computer name and disk name
  2. Open Settings -> Systems Preference -> Sharing to verify computer name and localhost name

References

Prabhakar Kasi iOS Developer, Front End Developer

Leave a Reply