Updated 03-Aug-2025
How to set and modify hostnames
Contents
hostname commands
hostnameandhostnamectlwill display the static, transient hostnames (hostnamectlalso provides other host information).sudo nano /etc/hostnamecan be used to edit the hostname that will be displayed upon reboot or restart.- This can be done more easily from the command with
sudo hostnamectl set-hostname NEWNAME
- This can be done more easily from the command with
Edit hosts file
sudo nano /etc/hosts
Add the hostname after localhost for local DNS lookup