commands.sh

hostnamectl

linux

Get or set the hostname of the computer.

More info →

Examples (4)

Get the hostname of the computer

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 ""
made by @shridhargupta | data from tldr-pages