Change Linux Hostname: Quick VM Guide
To change the hostname of a Linux virtual machine, you can follow these steps:
- Open the terminal window and enter the following command to view the current host name:
hostname
- Use the following command to change the hostname (replace “newhostname” with the desired new hostname):
sudo hostnamectl set-hostname newhostname
- The hostname file located in the /etc directory.
sudo nano /etc/hostname
- the hosts file located in /etc folder
sudo nano /etc/hosts
- Restart the virtual machine to apply the modified host name.
sudo reboot
After completing the above steps, your Linux virtual machine’s hostname will be successfully changed to the new one set.