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.
hostname Syntax:
hostname [option]
Options:
Option | Description |
---|---|
-f | Display the fully qualified domain name. |
-s | Display the short hostname. |
-i | Display the network address. |
-h | Display help information. |
Parameters:
Parameter | Description |
---|---|
No parameters. This command does not require any parameters. |
hostname Command Samples:
Display the current hostname
hostname
This command shows the current hostname of the system.
Change the hostname
sudo scutil --set HostName NewHostName
This command changes the hostname of the system to “NewHostName”.
Display the fully qualified domain name (FQDN)
hostname -f
Shows the fully qualified domain name of the system.
Display the local domain name
hostname -d
Displays the local domain name of the system.
Display the truncated hostname
hostname -s
Shows the truncated version of the hostname.
Display all information
hostname -A
Displays all the available information about the hostname.
Display the DNS domain name
hostname -y
Shows the DNS domain name of the system.
How do I display the current hostname in MacOS?
To display the current hostname in MacOS, use the following command:
hostname
How do I set a new hostname in MacOS?
To set a new hostname in MacOS, use the following command:
sudo scutil --set HostName <new_hostname>
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:
hostname -f
How do I display the local hostname in MacOS?
To display the local hostname in MacOS, use the following command:
hostname -s
How do I display the network hostname in MacOS?
To display the network hostname in MacOS, use the following command:
hostname -A
How do I set the local hostname in MacOS?
To set the local hostname in MacOS, use the following command:
sudo scutil --set LocalHostName <new_local_hostname>
Applications of the hostname command
- 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