Files
cheatsheet-tldr/tldr/linux/hostnamectl
2025-12-20 00:20:53 +00:00

26 lines
637 B
Plaintext

---
syntax: markdown
tags: [tldr, linux]
source: https://github.com/tldr-pages/tldr.git
---
# hostnamectl
> Get or set the hostname of the computer.
> More information: <https://www.freedesktop.org/software/systemd/man/latest/hostnamectl.html>.
- 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 ""`