Modify hostname in CentOS7 permanently

I need to configure hostname dm01 for CentOS7
It’s very simple,the steps as shown in following.

1.Execute following commnad.

hostnamectl set-hostname dm01

2.Edit file “/etc/hosts”,attaching “dm01” the end of localhost line
vi /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 dm01
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 dm01

3.Restart server and the hostname had been changed to “dm01”

Leave a Reply