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
- Edit /etc/hosts file, then replace the old Hostname with the new Hostname you want
- Edit /etc/hostname file, then replace the old Hostname with the new Hostname you want
- If you have edited the two files, reboot
- After rebooting, your Ubuntu Hostname will change, please check with the command hostname or hostnamectl
- The hostname was successfully changed, the Hostname change process did not take long, here’s the GIF I made in the Hostname change process
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
- 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
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 :
0 Comments