hostnamectl
Linux · System · reference only
What it does
Shows and changes the host name and other system data, such as the operating system and kernel, through systemd.
Syntax
hostnamectl [opciones] [orden]
Options and parameters
statusShows the host name, operating system and kernel; it is the default command.
set-hostname nombreChanges the host name.
hostnameShows only the host name.
--staticActs on the static name stored in /etc/hostname.
--transientActs on the transient name assigned by the network.
--prettyActs on the pretty name, which allows spaces and accents.
-H equipoRuns the command on a remote host over SSH.
Usage examples
hostnamectlShows the host name, operating system and architecture.
sudo hostnamectl set-hostname servidor1Changes the host name to servidor1 permanently.
hostnamectl hostnamePrints only the current name.
hostnamectl --staticShows the static name stored in /etc/hostname.
Notes and common mistakes
- The name change is permanent, but you should also update /etc/hosts if the machine resolves itself locally.