Showing posts with label change hostname in linux. Show all posts
Showing posts with label change hostname in linux. Show all posts

Thursday, April 4, 2013

Linux change hostame

Check the hostname:

[root@node1 ~]# hostname
node1


As we can see in our case the hostname is node1.

We want to change it to node1.oracle.com

Open the file /etc/sysconfig/network and change the value of  HOSTNAME parameter:

[root@node1 ~]# gedit /etc/sysconfig/network

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=node1.oracle.com
GATEWAY=192.165.2.105


Finally open the /etc/hosts file and make the proper changes

[root@node1 ~]# gedit /etc/hosts

The initial values

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1        node1 localhost.localdomain localhost
::1        localhost6.localdomain6 localhost6


The new values

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1    localhost.localdomain localhost
::1        localhost6.localdomain6 localhost6
192.165.2.105    node1.oracle.com    node1


Save the file and restart you system.

Check the hostname again:

root@node1 ~]# hostname
node1.oracle.com