I’ll introduce how to change the hostname in Linux.
As an example, let’s say we want to set the server hostname to codenote.net.
Add hostname to /etc/hosts
# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
↓(Add)
127.0.0.1 codenote.net localhost localhost.localdomain localhost4 localhost4.localdomain4
Change HOSTNAME in /etc/sysconfig/network
# vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain
↓(Change)
NETWORKING=yes
HOSTNAME=condenote.net
Apply hostname settings
If there are no particular issues, let’s restart the server.
# reboot -h now
If you don’t mind the console hostname, just restarting the network is OK.
# service network restart
That’s all from the Gemba.