software

How to Change Your MacBook Name in Terminal

You can change your MacBook name in Terminal by updating the computer name saved in macOS preferences and verifying the update with command-line tools. The primary command uses...

Mara Ellison
How to Change Your MacBook Name in Terminal

You can change your MacBook name in Terminal by updating the computer name saved in macOS preferences and verifying the update with command-line tools. The primary command uses sudo scutil --set ComputerName "NewName" to set the user-facing name, and, depending on needs, can include sudo scutil --set HostName "NewName" and sudo scutil --set LocalHostName "NewName" to control Bonjour and network-facing identifiers. Before applying changes, confirm the current values with scutil --get ComputerName, scutil --get HostName, and scutil --get LocalHostName. This evergreen explainer outlines exact syntax for macOS Sonoma and Ventura, expected behaviors, and common pitfalls so you can apply a durable, verifiable method that persists across updates.

macOS Name Architecture and Why Terminal Matters

macOS maintains three related name values that serve different roles, and Terminal gives precise control over each one. Understanding the distinction helps you avoid surprises when you change one identifier while leaving others unchanged.

ComputerName

The ComputerName is the friendly name shown in Finder, Sharing preferences, and many Apple interfaces. It is stored in the user-friendly preferences domain and is the default label when you connect to shared services or use screen-sharing tools.

HostName

HostName is used by networking software to identify the machine in command-line tools and some diagnostic traffic. It is often set to a short label without spaces and is relied upon by SSH and some scripts when the system resolves addresses.

LocalHostName

LocalHostName is the Bonjour name that other devices see on the local network. It typically appends .local and is used for discovery protocols, file sharing, and printer access without explicit configuration.

When you change your MacBook name in Terminal, you can target one, two, or all three values. Decide which identifier you need to adjust based on whether you are troubleshooting SSH access, preparing for screen sharing, or simply making your device easier to recognize in your local network.

Confirm Current Names Before Changes

Open Terminal and run the following three commands to see the current values. This baseline helps you confirm what will change and avoids overwriting a carefully configured setup.

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

For each command, Terminal prints the active value or an empty line if it is unset. If you receive an error, ensure you are running the command in the user context and that the Directory Service cache is not corrupted.

Safe Step-by-Step Instructions

Use this procedure to update your MacBook name in Terminal with minimal risk. These steps are compatible with recent macOS versions, including macOS Sonoma and macOS Ventura, and follow Apple-recommended practices.

Step 1. Open Terminal

Press Command-Space, type Terminal, and press Return. You can also open it from the Applications/Utilities folder.

Step 2. Decide on New Names

Choose a clear, short name without special characters to avoid unexpected behavior in scripts or network discovery. Spaces are allowed in ComputerName but may require escaping in some command-line tools.

Step 3. Set ComputerName

To change the friendly name shown in macOS UI and Sharing, run:

sudo scutil --set ComputerName "New Name"

Enter your admin password when prompted. The command updates the preference domain used by user-facing interfaces.

Step 4. Optionally Set HostName

If you need a network-ready hostname for SSH or scripts, run:

sudo scutil --set HostName newname

Use lowercase letters, hyphens, and numbers; avoid spaces. On many networks this value is used for command-line resolution.

Step 5. Optionally Set LocalHostName

To control the Bonjour name visible as newname.local, run:

sudo scutil --set LocalHostName newname

Keep LocalHostName alphanumeric and short for best compatibility with discovery protocols.

Step 6. Verify the Changes

Re-run the three get commands from the earlier section. Confirm that ComputerName, HostName, and LocalHostName now reflect the values you set.

Verification and Expected Behavior

After you change your MacBook name in Terminal, expect these behaviors. Changes written with sudo scutil persist across reboots and macOS updates under normal conditions.

Identifier Command Used Primary Effect
ComputerName sudo scutil --set ComputerName "NewName" Displays friendly name in Finder, Sharing, and user interfaces
HostName sudo scutil --set HostName newname Sets network-facing name used by SSH and some diagnostic tools
LocalHostName sudo scutil --set LocalHostName newname Sets BonBonjour name, visible as newname.local on the LAN

Confirm with Hostname

The hostname command typically returns the HostName value. Use it to double-check resolution in your environment, for example:

  • hostname
  • hostname -f

Confirm Bonjour Names

On the local network, other devices may resolve newname.local if mDNS is working. Tools such as dns-sd can list available services and verify the advertised name.

Common Pitfalls and Fixes

When you change your MacBook name in Terminal, a few issues can appear. These are often related to mismatched naming schemes, cached lookup data, or incomplete verification steps.

  • Using spaces in HostName or LocalHostName may cause some tools to misinterpret the name; prefer hyphens instead.
  • After changing names, restart network services or reboot if services do not immediately reflect the updated identifier.
  • If you see stale entries, flush the mDNS cache with sudo dscacheutil -flushcache and sudo killall -HUP mDNSResponder.
  • Do not rely on changing the HostName alone to alter Finder display; use ComputerName for UI labels.

When to Apply Each Identifier

Choose which identifier to change based on your workflow. If you mainly need a clearer label when sharing screens or devices, update ComputerName. If you rely on consistent SSH hostnames, update HostName. For smooth Bonjour discovery on Wi-Fi or local subnets, update LocalHostName.

  • User-facing visibility: ComputerName
  • Command-line and SSH: HostName
  • Bonjour and local network discovery: LocalHostName

Security and Scope Notes

Changing your MacBook name in Terminal requires administrator privileges because it modifies system preference domains. The changes affect all users on the machine and remain intact until altered again or overridden by configuration management tools. This method does not alter host certificates, directory bindings, or enrollment profiles; it only updates descriptive identifiers used for display and discovery.

Conclusion and Durable Use

You can change your MacBook name in Terminal safely and verify the update with built-in commands. By applying the correct scutil syntax, confirming values with get commands, and understanding which identifier serves each purpose, you establish a repeatable, evergreen process. These steps remain effective across macOS updates and support clear naming, accurate sharing, and reliable network discovery over time.

Related Reading

More pages in this topic cluster.

How to Migrate Data From One Mac to Another: A Verified Step-by-Step Guide

Migrating data from one Mac to another is usually straightforward if you plan the workflow and choose the right transfer method. This guide explains the most reliable options—...

Read next
Pixel Drawing Software: A Comprehensive Guide to Tools, Techniques, and Best Practices

Pixel drawing software enables artists and designers to create detailed graphics at the pixel level, offering precise control over color, shape, and texture. These tools are fou...

Read next
Car Service Reminder App: How It Works and Why It Matters

A car service reminder app is a digital tool that tracks maintenance intervals, stores records, and prompts you when service is due. Instead of relying on paper receipts or memo...

Read next