Thursday, January 6, 2011

Linux change hostname

Display Hostname
Type the following command:

hostnameSample ouputs:

server.nixcraft.net.inStep # 1: Change Hostname
You need to update two files:

Linux Distribution specific file. Edit appropriate file as per your distribution as follows.
/etc/hosts
Redhat / CentOS / Fedora: Change Hostname
Edit /etc/sysconfig/network, enter:

vi /etc/sysconfig/networkSet HOSTNAME=newhost.example.com, enter:

HOSTNAME=server2.nixcraft.comSave and close the file. Type the following command:

hostname server2.nixcraft.com
hostname


Step #2: Update /etc/hosts
Now, you need to edit /etc/hosts file, enteR:

vi /etc/hostsChange all old hostname with newer one.

No comments:

Post a Comment