hostname
system administrationLinux/Unix
The hostname command is one of the most frequently used commands in Linux/Unix-like operating systems. hostname Show or set the system hostname
Quick Reference
Command Name:
hostname
Category:
system administration
Platform:
Linux/Unix
Basic Usage:
hostname [options] [arguments]
Common Use Cases
Syntax
hostname [options] [name]
Options
Option | Description |
---|---|
-a, --alias |
Display the alias name of the host (if used) |
-d, --domain |
Display the DNS domain name |
-f, --fqdn, --long |
Display the FQDN (Fully Qualified Domain Name) |
-i, --ip-address |
Display the IP address(es) of the host |
-I, --all-ip-addresses |
Display all network addresses of the host |
-s, --short |
Display the short hostname |
-y, --yp, --nis |
Display the NIS/YP domain name |
--help |
Display help information and exit |
--version |
Output version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the hostname
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
hostname