Product SiteDocumentation Site

3.3. Configuring Host Names Using nmcli

The NetworkManager tool nmcli can be used to query and set the static host name in the /etc/hostname file. Note that at time of writing, changing the host name in this way will not be noticed by hostnamectl.
To query the static host name, issue the following command:
~]$ nmcli general hostname
To set the static host name to my-server, issue the following command as root:
~]# nmcli general hostname my-server
To force hostnamectl to notice the change in the static host name, restart hostnamed as root:
~]# systemctl restart systemd-hostnamed