How to change the hostname on Ubuntu?

Windows Articles

How to permanently delete files in Windows 10

Hello, how are you? As we use the computer, it fills up with files and information. Indeed, the user is used to...

How to improve your sleep with your Android device

Every day new apps are released for our Android device, focused on different aspects of our lives. It is a world full...

Install Python 3.9 on Ubuntu 20.04 / 18.04

Hi, folks. In this post, I will show you how to install Python 3.9 on Ubuntu 20.04 / 18.08

How to Install MinGW on Windows 10

Hello! We usually work with many applications in Windows 10. However, some applications are more delicate than others. For example, native applications....

How to install Apache Tomcat on Ubuntu 20.04 / Debian 10?

Even though Python is the most popular programming language actually, there is still confidence in Java. So you probably needed to make applications with...
angeloma
angeloma
Senior Writer and partner

This simple tutorial will teach you how to change the hostname on Ubuntu. The steps we will tell you here will work for all versions of 16.04 for here including derivatives like Linux Mint or ElementaryOS. Although this is a simple post, it can be useful for anyone who has Ubuntu on a network.

What is the Hostname?

Briefly, a hostname is a unique name for a computer or network connection on a network. This name is a string of characters that help identify a computer on the network. It must be unique since there may be packet loss and some services may not work properly.

In other words, the hostname allows you to distinguish between devices on a local network. Besides, it allows computers to locate others, making it possible to exchange data within a network.

On the other hand, the hostname is used on the Internet as part of the Fully Qualified Domain Name that should not be confused.

But the aim of this post is that we learn how to change it in Ubuntu.

Change the Hostname in Ubuntu

In this tutorial, we will use the terminal. This is so that you can take advantage of it both on a server and your desktop system.

So, open your terminal or start an SSH session. If you use the GNOME interface you can open a terminal by pressing the keys CTRL + ALT + T

Then, check what your hostname is. To do this, run it:

hostname

You will get a simple output where you will see the hostname.

If you want a little more information related to the hostname you can use the command hostnamectl

hostnamectl
Static hostname: laptop
Icon name: computer-laptop
Chassis: laptop
Machine ID: 16fa2990e5014c52bbca62e8a9eb3558
Boot ID: 25860d46c0c94da5a8a5a344a237d81f

Now, you know what the hostname is in your system, it’s time to change it.

The easiest and most practical way is to use the hostnamectl command. To change it, follow this syntax:

sudo hostnameclt set-hostname [new-hostname]

For example:

sudo hostnameclt set-hostname osradar

And it’s that simple. Check the hostname command again and you will see the change reflected.

Change the Hostname in Ubuntu permanently

The above method is temporary. This means that when the computer is restarted, the changes will be reversed. To make the change permanent, you have to do the previous step but another one.

After you’ve changed the hostname with the previous command open the file /etc/hosts and replace any indication of the old hostname with the new one.

sudo nano /etc/hosts

Then, save the changes and reboot the system.

Now the change has been permanent.

Conclusion

Changing the hostname is quite easy but for many it can’t waste any time. So this is important to know and keep in mind for daily work.

So, please share this post and join our Telegram Channel.

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to permanently delete files in Windows 10

Hello, how are you? As we use the computer, it fills up with files and information. Indeed, the user is used to...

How to improve your sleep with your Android device

Every day new apps are released for our Android device, focused on different aspects of our lives. It is a world full...

Install Python 3.9 on Ubuntu 20.04 / 18.04

Hi, folks. In this post, I will show you how to install Python 3.9 on Ubuntu 20.04 / 18.08

How to Install MinGW on Windows 10

Hello! We usually work with many applications in Windows 10. However, some applications are more delicate than others. For example, native applications....

How to install Apache Tomcat on Ubuntu 20.04 / Debian 10?

Even though Python is the most popular programming language actually, there is still confidence in Java. So you probably needed to make applications with...
x