Changing the HOSTNAME on Oracle Enterprise Linux

Either due to cloning or corporate naming standards, you may find the need to change the hostname of an Oracle Enterprise Linux System.

The current hostname for this machine is odlinux.oracledistilled.com and it will be changed to secondary.oracledistilled.com. The hostname can be changed by editing /etc/sysconfig/network as the root user.

[root@odlinux ~]# hostname
Odlinux.oracledistilled.com
[root@odlinux ~]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=odlinux.oracledistilled.com
[root@odlinux ~]#

[root@odlinux ~]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=secondary.oracledistilled.com
[root@odlinux ~]#

After changing the hostname in you should also change the hostname in /etc/hosts.

[root@secondary ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost
192.168.4.111   wrath.oracledistlled.com        wrath
192.168.4.115   secondary.oracledistilled.com   secondary
::1             localhost6.localdomain6 localhost6
[root@secondary ~]#

While changing the host name is fairly easy care should be taken with applications that might already be installed on the system. Many applications will store the hostname of the system in configuration and start up files at the time of installation. You should check your applications and update their configurations with the new hostname.

3 thoughts on “Changing the HOSTNAME on Oracle Enterprise Linux”

  1. Why not use “hostname -b” to set the host name, and “domainname” to set the domain name?

    Looks like your /etc/hosts file is for a machine with a static IP address. How can the host name be changed on a machine which will receive an address from DHCP?

Leave a Reply

Your email address will not be published. Required fields are marked *