hostnamectl
Get or set the hostname of the computer. More information: https://manned.org/hostnamectl.
- 
Get the hostname of the computer:
 hostnamectl
- 
Set the hostname of the computer:
 sudo hostnamectl set-hostname "{{hostname}}"
- 
Set a pretty hostname for the computer:
 sudo hostnamectl set-hostname --static "{{hostname.example.com}}" && sudo hostnamectl set-hostname --pretty "{{hostname}}"
- 
Reset hostname to its default value:
 sudo hostnamectl set-hostname --pretty ""
License and Disclaimer
The content on this page is copyright © 2014—present the tldr-pages team and contributors.This page is used with permission under Creative Commons Attribution 4.0 International License.
While we do attempt to make sure content is accurate, there isn't a warranty of any kind.