hostname / hostnamectl

How to set and modify hostnames

hostname commands

  • hostname and hostnamectl will display the static, transient hostnames (hostnamectl also provides other host information).
  • sudo nano /etc/hostname can 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

Edit hosts file

sudo nano /etc/hosts

Add the hostname after localhost for local DNS lookup

We use cookies only for WordPress functionality, and do not use third-party analytics or tracking.
Accept