Query and set the system hostname, OS info, and machine identity.
low risk
hostnamectl manages three hostname types: static (persistent, stored in /etc/hostname), transient (runtime, overridden by DHCP), and pretty (human-readable display name). Running without arguments shows OS, kernel, hardware, and virtualization info — useful for inventory scripting.
| Flag | Meaning |
|---|---|
set-hostname | Set the static system hostname persistently |
--static | Target the static hostname specifically |
--transient | Target the transient (runtime) hostname |
--pretty | Target the pretty (human-readable) hostname |
hostnamectlDisplay full system identity: hostname, OS, kernel, arch, virtualization type · explain & risk-check →hostnamectl set-hostname prod-web-01Permanently rename the system to prod-web-01 · explain & risk-check →hostnamectl set-hostname 'Production Web Server 01' --prettySet a human-friendly pretty hostname that can include spaces · explain & risk-check →After setting a new hostname, update /etc/hosts to map 127.0.1.1 to the new name — tools that do reverse DNS lookups will otherwise hang.
Reference text is hand-written and may be incomplete — check man hostnamectl for your version. Test destructive commands on a non-production system first.