In order to change or set a CentOS 7 machine hostname, use the hostnamectl command as shown in the below command excerpt.

# 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
Was this answer helpful? 0 Users Found This Useful (0 Votes)