hostnamectl — host name and machine info
cheat sheet · Ubuntu 24.04 · systemd https://lab.dimsanych.ru/en/wiki/hostnamectl/Cheat sheet
-
hostnamectlname + machine info -
hostname -fFQDN -
hostname -Iall IP addresses -
sudo hostnamectl set-hostname web01 - + /etc/hosts: 127.0.1.1 web01.example.com web01
- VM clone: truncate -s0 /etc/machine-id && systemd-machine-id-setup
Options
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.