This guide will enable you to change your server hostname in Ubuntu via SSH.
In order to change your server hostname, the first step to take is to access your server via an SSH terminal tool such as putty.
Then once logged in, you will first enter the following command;
sudo hostname newHostname
Where the new hostname used here is "newHostname"
Next, use the following command to enter the hostname Directory where you will see the current or default hostname;
sudo nano /etc/hostname
You have to edit the current hostname to the new one let’s say (newHostname), and save it.
Then, you must go to the "hosts" Directory and therein you will add the server ip and its corresponding hostname in same line thereby maintaining a linking format. Use the command below;
sudo nano /etc/hosts
Let’s say your server ip is 127.1.2.1 and the new server hostname is newHostname , then you will simply place them in a single line like this;
As soon as you have added the above, then save and close.
Now you can restart your server network with the following command;
If you are having problems in changing your server hostname in Ubuntu, you are fine to contact us via our Contact Page for further support.