hostnamectl

Query and set the system hostname, OS info, and machine identity.

low risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
What it does

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.

Common flags
FlagMeaning
set-hostnameSet the static system hostname persistently
--staticTarget the static hostname specifically
--transientTarget the transient (runtime) hostname
--prettyTarget the pretty (human-readable) hostname
Examples
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 →
Pro tip

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.

Related
hostname timedatectl localectl
Open the full explainer →More in System & Processes

Reference text is hand-written and may be incomplete — check man hostnamectl for your version. Test destructive commands on a non-production system first.