Pages

Sunday 1 December 2013

How to change Hostname on Oracle Solaris and Linux

Step # 1: Change Hostname

You need to update two files:
  1. Linux Distribution specific file. Edit appropriate file as per your distribution as follows.
  2. /etc/hosts

Redhat / CentOS / Fedora: Change Hostname

Edit /etc/sysconfig/network, enter:
vi /etc/sysconfig/network
Set HOSTNAME=newhost.example.com, enter:
HOSTNAME=server2.nixcraft.com
Save and close the file. Type the following command:
hostname server2.nixcraft.com
hostname
Now, proceed to step # 2.

Debian / Ubuntu: Change Hostname

Edit, /etc/hostname file, enter:
vi /etc/hostname
Delete old name and add new name:
server2.nixcraft.com
Save and close the file. Type the following command:
hostname server2.nixcraft.com
hostname
Now, proceed to step # 2.

Slackware: Change Hostname

Edit /etc/HOSTNAME, enter:
vi /etc/HOSTNAME
Delete old name and add new one:
server2.nixcraft.com
Save and close the file. Type the following command:
hostname server2.nixcraft.com
hostname
Now, proceed to step # 2.

Suse / OpenSuse: Change Hostname

Edit /etc/HOSTNAME, enter:
Delete old name and add new one:
server2.nixcraft.com
Save and close the file. Type the following command:
hostname server2.nixcraft.com
hostname
Now, proceed to step # 2.

Step #2: Update /etc/hosts

Now, you need to edit /etc/hosts file, enteR:
vi /etc/hosts
Change all old hostname with newer one.

No comments:

Post a Comment