sudo hostnamectl set-hostname myserver

Category: Self-Hosting

sudo hostnamectl set-hostname myserver

Set the server's hostname — used in logs, prompts, and service discovery

Changes the server's hostname — what appears in the terminal prompt, log files, and when other services identify this machine.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.