How To Find And Change Your Hostname On An Ubuntu System
In this tutorial we will look at how to change the hostname of your Ubuntu Linux system. The following steps will work both on the desktop and server platform.
How To Check What The Hostname is:
Open up a termnial or ssh into the machine that you want to check. Enter the following command.
You should now see your hostname
How To Change Ubuntu Hostname:
To change the hostname you will need to edit the hostname file located in the /etc directory. We will also need to update the hosts file. In this example i will update my hostname from ubuntu-server to server100.
sudo nano /etc/hostname
Enter your password
Change the name in this file. In this example my current name is ubuntu-server and I will change it to server100.
Hit CTRL + X to exit nano
Enter Y to save changes
The /etc/hosts file holds some static DNS information.If this is not set somethings can get a little weird at times. We will use the nano text editor again to make our changes.
sudo nano /etc/hosts
You will need to change your old hostname to the new one.
Note: The loven.linux was handed out by my DNS server when I setup my machine. Yours will be something different.
Hit CTRL + X to exit out of nano
Enter Y to save the file
Hit enter to overwrite the file.
Restarting The System:
Now that we have everything configured all we should need to do is restart and check to make sure the hostname has been update.
sudo shutdown -r now
If you enjoyed this post, please share it on your favorite social network by clicking on the “Share / Save” bar below.