How to update / change hostname on Ubuntu 18.04/18.10 Server
How to Change Hostname in Ubuntu 18.04 / 18.10 (Change Computer Name)
In this tutorial we will see How to Change Hostname in Ubuntu 18.04/18.10 system. This method will work without the need of restarting your computer.
A hostname is a label that identifies a machine on a network. You shouldn’t use the same hostname on two different machines on a same network.
The hostname is set at the time when the Ubuntu operating system is installed or if you are spinning up a virtual machine it is dynamically assigned to the instance at startup.
Display the Current Hostname
Use hostnamectl command to retrieve a current system hostname:
# sudo hostnamectl
As you can see in the image above, the current hostname is set to srv1.
Change the Hostname
The following steps outline how to change the hostname in Ubuntu 18.04 / 18.10.
Change the hostname using hostnamectl
In Ubuntu 18.04 we can change the system hostname and related settings using the command hostnamectl.
$ sudo hostnamectl set-hostname lintut
To verify that the hostname was successfully changed, once again use the hostnamectl command:
You should see your new server name printed on the console.
In this tutorial we have shown you how to easily change your Ubuntu server hostname without restarting the machine.