Skip to content

hostname MacOS Command Guide

The hostname command in MacOS allows users to view or set the hostname of their computer system. The hostname is used to identify the device on a network, and changing it can be useful for various reasons. This guide will explain the syntax of the hostname command, along with the available options for viewing and setting the hostname. Whether you need to troubleshoot network issues, customize your system’s identification, or simply understand more about MacOS commands, this guide will provide you with the information you need.

Terminal window
hostname [option]
OptionDescription
-fDisplay the fully qualified domain name.
-sDisplay the short hostname.
-iDisplay the network address.
-hDisplay help information.
ParameterDescription
No parameters. This command does not require any parameters.
Terminal window
hostname

This command shows the current hostname of the system.

Terminal window
sudo scutil --set HostName NewHostName

This command changes the hostname of the system to “NewHostName”.

Display the fully qualified domain name (FQDN)

Section titled “Display the fully qualified domain name (FQDN)”
Terminal window
hostname -f

Shows the fully qualified domain name of the system.

Terminal window
hostname -d

Displays the local domain name of the system.

Terminal window
hostname -s

Shows the truncated version of the hostname.

Terminal window
hostname -A

Displays all the available information about the hostname.

Terminal window
hostname -y

Shows the DNS domain name of the system.

How do I display the current hostname in MacOS?

Section titled “How do I display the current hostname in MacOS?”

To display the current hostname in MacOS, use the following command:

Terminal window
hostname

To set a new hostname in MacOS, use the following command:

Terminal window
sudo scutil --set HostName <new_hostname>

How do I display the fully qualified domain name (FQDN) of the system in MacOS?

Section titled “How do I display the fully qualified domain name (FQDN) of the system in MacOS?”

To display the fully qualified domain name (FQDN) of the system in MacOS, use the following command:

Terminal window
hostname -f

How do I display the local hostname in MacOS?

Section titled “How do I display the local hostname in MacOS?”

To display the local hostname in MacOS, use the following command:

Terminal window
hostname -s

How do I display the network hostname in MacOS?

Section titled “How do I display the network hostname in MacOS?”

To display the network hostname in MacOS, use the following command:

Terminal window
hostname -A

To set the local hostname in MacOS, use the following command:

Terminal window
sudo scutil --set LocalHostName <new_local_hostname>
  • Display the current hostname of the macOS system
  • Set or change the hostname of the macOS system
  • Display the Fully Qualified Domain Name (FQDN) of the macOS system
  • Display the local domain name of the macOS system