This article describes the how the change the hostname in Linux machine.
- Open the network file.
# sudo vi /etc/sysconfig/network
- Modify the HOSTNAME= value with your domain name. Example hostname is “myhostname”
HOSTNAME = myhostname
- To access with in the server add it in /etc/hosts file
- Run the “hostname” command. This command lets you change the hostname on the server that the command line remembers, but it does not actively update all programs that are running under the old hostname.
[root ~]# hostname myhostname [root]# hostname myhostname [root ~]#
- Restart networking on your server to ensure that changes will persist on restart.
# /etc/init.d/network restart