Indonesia Website Awards
Indonesia Website Awards

How to change hostname on Ubuntu 20.04? This question often arises for new Linux users. We can change the Hostname in 2 ways, here are the ways:

1. Change Hostname on Ubuntu 20.04 Permanently

In this first method, we need to edit 2 files namely the file /etc/hosts and /etc/hostname. The steps are as follows:

  • To check the current hostname, you can run the command hostname or hostnamectl
hostname command

Hostname Command

  • Edit /etc/hosts file, then replace the old Hostname with the new Hostname you want
change hosts

Change Hosts File

  • Edit /etc/hostname file, then replace the old Hostname with the new Hostname you want
change hostname

Change Hostname File

  • If you have edited the two files, reboot
reboot server

Reboot Your Ubuntu

  • After rebooting, your Ubuntu Hostname will change, please check with the command hostname or hostnamectl
change hostname success

Change Hostname Success

  • The hostname was successfully changed, the Hostname change process did not take long, here’s the GIF I made in the Hostname change process
Change Hostname Ubuntu Permanently

Change Hostname Ubuntu Permanent

 

2. Change Hostname on Ubuntu 20.04 without Restart/Reboot

If you want to change Hostname without rebooting your Ubuntu. You can use hostnamectl command to change the Hostname. here are the steps:

  • To check the current hostname, as in the first method, you can use the command hostname or hostnamectl
  • Next, you can directly change the hostname with the command

hostnamectl set-hostname newHostname

change hostname on ubuntu with hostnamectl command

Change Hostnamectl

  • Here you don’t need to restart/reboot your Ubuntu and the Hostname has been successfully changed. The hostname change process doesn’t take long, here’s a GIF I made in the process of changing Hostname without restarting/rebooting
change hostname without reboot

Change Hostname Ubutnu without Reboot

Hostname change has been successful!

Alright, that’s my short information about how to change hostname on Ubuntu 20.04. Hopefully this information can be useful. Thanks for reading 😀

 

Read Also :

How to Remote Server with Visual Studio Code

How to Clear Cache on Linux

How to Install IPsec VPN Server on Linux

Categories: Linux

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *