This article continues our series on the common commands every Mac admin must know. The first article in the series explored how to enable SSH to access a remote Mac’s Shell securely.
Whether you work for a small, mid-size, or large enterprise, knowing how to change a Mac’s name is important. You likely manage more than one computer, and discretely naming each device will allow you to identify and distinguish between them. Unique names — customized to your preferred naming conventions — make collaborative work easier, such as sending and sharing files between different computers.
In this article, we will explore how to rename computer name, hostname, and local hostname on macOS.
What Is Computer Name, Hostname, and Bonjour Hostname?
As the name implies, a computer name is a user-friendly label used to identify your computer. Similarly, a hostname is an identifier assigned to a computer in a computer network. It is used to identify the device in various network communications, and can be used when connecting to it via SSH (Secure Socket Shell) for remote login.
Your Mac’s bonjour name is also known as its local hostname. It allows the computers on your local network to access and connect with your computer. You can see your Mac’s local hostname beneath the computer name by navigating through System Preferences > Sharing.
For instance, in Figure 1, the computer name is JumpCloud Platform and the local hostname is jumpcloud-platform.local.
How to Rename Computer Name, Hostname, and Bonjour Name via the Terminal
You can customize how your MacBook appears with the use of the scutil command via the terminal. In this section, we will explore how to use the scutil command to change a Mac’s computer name, hostname, and bonjour (local host) name.
Changing the Computer Name
Launch the terminal app on your MacBook.
You can do this by searching “terminal” in the Spotlight search option of your computer or by navigating through Applications > Utilities > Terminal.
To rename the computer name, enter and execute the following scutil command:
sudo scutil –set ComputerName YourComputerName
For example, to rename our computer name from JumpCloud to JumpCloud1, we only need to execute the following command via the terminal (refer to Figure 2):
sudo scutil –set ComputerName JumpCloud1
You may be required to provide your password when you run the command; therefore, input the password accordingly. Note that we added sudo to the command to elevate admin privileges.
Confirm the Change to the Computer Name
After renaming the computer, the terminal will not display any message or notification to confirm the success of the change. However, you can use the
–get flag to check your work. All you need to do is to run and execute the text below. As seen in Figure 3, the computer name is now JumpCloud1.
sudo scutil –get ComputerName
Changing the Hostname
To rename the hostname, we will follow a procedure similar to what we did when renaming the computer name. Open the terminal and run the following scutil command:
sudo scutil –set HostName YourHostName
For example, we would like to rename our hostname from jumpcloud to jumpclouddirectory.example.com by running the command below (Figure 4):
sudo scutil –set HostName jumpclouddirectory.example.com
To confirm the change, we need to run the following command:
sudo scutil –get HostName
As seen in Figure 4, the new hostname is jumpclouddirectory.example.com.
Changing the Local Hostname
Changing your Mac’s bonjour name (also known as the local hostname) follows the same procedure as the two previous tasks. All you need to do is to run the scutil command below:
sudo scutil –set LocalHostName YourLocalHostName
For example, we can change our computer’s local hostname from jumpcloud-platform.local to jumpcloud-seamless.local (Figure 5).
sudo scutil –set LocalHostName jumpcloud-seamless
Like the previous tasks, you will not get any notification or message after renaming the bonjour name. However, you can confirm the success of the task by running the following command:
sudo scutil –get LocalHostName
As seen in Figure 5, the local hostname is now jumpcloud-seamless.
Taking the Alternative GUI Route
In addition to renaming your computer name and local hostname via the terminal, you can also navigate through System Preferences > Sharing to make the changes. Once in the Sharing pane, simply type your preferred computer name in the field provided as shown in Figure 6. Then, click Edit to change the local hostname. A pop-up will appear where you can insert your preferred local hostname. Afterwards, click on OK (Figure 7).
You now understand how to use the scutil command to rename your macOS computer name, hostname, and local hostname. As a Mac admin, this understanding will help you work smarter as you manage multiple macOS systems.
You may also want to consider leveraging a cloud directory platform like JumpCloud to easily manage all of your macOS, Windows, and Linux devices. From a single cloud-based admin console, you can manage access, user privileges, and security settings across your entire fleet. You can even set up the name change commands in the Commands section of the JumpCloud console and then assign the commands to device groups as needed.
Test out the full functionality of our platform in your own environment by signing up for JumpCloud Free today. You can manage up to 10 users and 10 devices for as long as you need without paying a cent. For the first 10 days, enjoy 24/7 premium in-app chat support every step of the way.