Beginner
Package: systemd
hostnamectl
View or set the system hostname and related metadata.
Syntax
hostnamectl [command]
Description
hostnamectl shows and controls the system hostname along with related identity details (operating system, kernel, virtualization), and is the systemd-native replacement for editing /etc/hostname by hand.
Examples
hostnamectl
Show the current hostname and system details
sudo hostnamectl set-hostname web01
Set a new static hostname
hostnamectl status
Show the same status information explicitly
systemd-based distributions only.