hostname persistent – permanently without restart

Change hostname on Ubuntu without restart

To change the hostname permanently without a restart enter the following command:

hostnamectl set-hostname myhostname

To verify:

  1. /etc/hostname contains name of the machine, as known to applications that run locally. /etc/hosts and DNS associate names with IP addresses. hostname may be mapped to whichever IP address the machine can access itself, but mapping it to

/etc/hostname: CONTAINS myhostname

/etc/hosts: CONTAINS THE MAPPING:   localhost.localdomain   localhost myhostname
::1          localhost.localdomain   localhost myhostname



linux hostname permanently persistent

Leave a Reply