The hostnamectl
command is used to manage the system hostname and related settings in Linux. It allows users to view and change the hostname, as well as configure other related parameters such as the static hostname, transient hostname, and pretty hostname.
The basic syntax of the hostnamectl
command is as follows:
hostnamectl [options] [arguments]
set-hostname
: Set the system’s hostname.set-icon-name
: Set the icon name for the system.set-chassis
: Set the chassis type of the system.status
: Show the current hostname and related settings.help
: Display help information about the command.hostnamectl status
hostnamectl set-hostname my-new-hostname
hostnamectl set-hostname "My New Hostname" --pretty
hostnamectl set-chassis desktop
hostnamectl status
before making changes.