HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

hostnamectl — Get or set the hostname of the computer. More information: <https://www.freedesktop.org/software/sys

Submitted by: @import:tldr-pages··
0
Viewed 0 times
thecommandhostnamectlhostnameclisetget
linux

Problem

How to use the hostnamectl command: Get or set the hostname of the computer. More information: <https://www.freedesktop.org/software/systemd/man/latest/hostnamectl.html>.

Solution

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 ""

Code Snippets

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 ""

Context

tldr-pages: linux/hostnamectl

Revisions (0)

No revisions yet.