Linux Mint

How to Change Hostname on Linux Mint 20

How to Change Hostname on Linux Mint 20
Hostname enables us to identify a device over the network. The hostname is set on your device during the installation process, or we can change it anytime on our virtual machine. A conflicting situation can arise if more than one device has a similar hostname and is connected to the same network.

Explaining the Hostname

In Linux Mint, we can get the hostname information and edit it using the hostnamectl command. There are following three different types of hostname in Linux Mint:

Check the current hostname

We can check the current hostname of the device by using the hostnamectl command:

$ hostnamectl

My current static hostname is Linux.

Changing the Hostname on Linux Mint 20

We can change the Hostname on Linux Mint by two methods:

We will discuss these two methods for changing the hostname.

Using hostnamectl command to change the hostname

It is very simple and straightforward to change the hostname by using the hostnamectl command. Follow the below-given command syntax to change the hostname:

$ sudo hostnamectl set-hostname

I am changing my Linux Mint system hostname to linuxhint from Linux:

$ sudo hostnamectl set-hostname linuxhint

Now let's check our new hostname with the command:

$ hostnamectl

As you can see from the output that my static hostname is changed to linuxhint.

To change the pretty hostname, use the hostnamectl command with -pretty option as follows:

$ sudo hostnamectl set-hostname "Kamran's laptop" --pretty

To check the pretty hostname, use the command:

$ hostnamectl

The pretty hostname value is updated.

Changing the hostname from /etc/hostname file

Open the /etc/hostname file in the nano editor by typing on the terminal:

$ sudo nano /etc/hostname

The /etc/hostname file opened in the nano editor.

Now, change the hostname here.

Once you have changed the hostname, save the file and run the hostnamectl command again:

$ hostnamectl

You can see that the static hostname is changed to Linux.

In many situations, the hostname is mapped to the localhost (127.0.0.1). This information is stored in the /etc/hosts file. Open the /etc/hosts file and change the hostname:

$ sudo nano /etc/hosts

Let's change the linuxhint to Linux, save, and exit the file.

The hostname will be updated successfully.

Conclusion

We can change the hostname on Linux Mint 20 in a couple of ways, i.e., from the hostnamectl command and by editing the /etc/hostname file. This article explains the hostname and describes the methods to change the hostname on Linux Mint 20 system.

Cara Menggunakan Xdotool untuk Merangsang Klik dan Penekanan Tetikus di Linux
Xdotool adalah alat baris arahan sumber terbuka dan bebas untuk mensimulasikan klik dan tekan kekunci tetikus. Artikel ini akan merangkumi panduan rin...
5 Produk Tetikus Komputer Ergonomik Teratas untuk Linux
Adakah penggunaan komputer yang berpanjangan menyebabkan rasa sakit di pergelangan tangan atau jari anda? Adakah anda mengalami sendi kaku dan selalu ...
Cara Mengubah Tetapan Tetikus dan Pad Sentuh Menggunakan Xinput di Linux
Sebilangan besar pengedaran Linux dihantar dengan perpustakaan "libinput" secara lalai untuk menangani peristiwa input pada sistem. Ia dapat memproses...