Without a subcommand, hostnamectl prints the static facts: name, OS, kernel,
virtualization, machine-id. With set-hostname it changes the name — by
default it sets static and pretty together unless you name
--static/--transient/--pretty explicitly. -H runs the operation on a
remote machine over SSH, without an interactive login to it.
| Option |
What it does |
Example |
--static |
Show only the static name (from /etc/hostname). |
hostnamectl --static |
--transient |
Show or set the transient name (from DHCP/mDNS, until reboot). |
hostnamectl set-hostname web01 --transient |
--pretty |
Show or set the pretty name for the UI — spaces and UTF-8 allowed. |
hostnamectl set-hostname "Веб 01" --pretty |
--json short|pretty|off |
Print the machine info as JSON. |
hostnamectl --json=pretty |
-H --host host |
Perform the operation on a remote machine over SSH. |
hostnamectl -H user@host |
--no-ask-password |
Do not prompt for a password interactively (for scripts). |
hostnamectl --no-ask-password set-hostname web01 |
Nothing found. Try a shorter query.