Monday, November 12, 2018

change hostname

On Ubuntu:

1. Press Ctrl+Alt+T on keyboard to open the terminal. When it opens, run the below command:
hostname NEW_NAME_HERE
This will change the hostname until next reboot. The change won’t be visible immediately in your current terminal. Start a new terminal to see the new hostname.
2. To change the name permanently, run command to edit the host files and change the name.And restart the machine after that:
sudo gedit /etc/hostname /etc/hosts
Reference


One more approach working on CentOS: Reference

hostnamectl set-hostname your-new-hostname
In addition to hostname command you can also use hostnamectl command to display a Linux machine hostname.
# hostnamectl
In order to apply the new hostname, a system reboot is required, issue one of the below commands in order to reboot a CentOS 7 machine.
# init 6
# systemctl reboot
# shutdown -r

No comments:

Post a Comment