$ hostname
Show or set the system hostname
DOCUMENTEDSystem informationUbuntu 24.04 LTS baseline
Synopsis
hostname [OPTION]... [NAME]
What it does
- Without an argument, `hostname` prints the current host name.
- Changing the hostname generally requires appropriate privileges and may not persist across reboots depending on how the system is configured.
Examples
Show the current hostname
hostnameShow the hostname from DNS if configured
hostname -fImportant details
These examples are intentionally conservative. Command behavior can still depend on filesystem state, permissions, locale, shell, installed package version, and other system configuration.
For exact option semantics, the linked authoritative documentation is the source of truth.