1842334 Members
2870 Online
110188 Solutions
New Discussion

Changing Host Name

 
mohammed arafat_2
Frequent Advisor

Changing Host Name

Hi All

Can i Change my Server Host name by command line?
i need to make a script to change my server name to a differnet one
Thank You

AFT
Arafat
4 REPLIES 4
Steven E. Protter
Exalted Contributor

Re: Changing Host Name

hostname is changed in the file /etc/rc.config.d/netcnof

You can also change the hostname with sam, but it does the same thing.

Its best to do such things and then boot the machine.

Note that many application products such as oracle, sendmail, omniback, openspool will require rconfiguration after a hostname switch.

If you use DNS for name resolution, don't forget to update that database.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Rita C Workman
Honored Contributor

Re: Changing Host Name

The best way is to change it using set_parms hostname command....that way the system handles changing all the files that need to be changed.

HTH
Rita
Patrick Wallek
Honored Contributor

Re: Changing Host Name

Yes, have a look at the hostname command.

# man hostname

You can also set up aliases within /etc/hosts so that you don't have to change the hostname.

Something like this in /etc/hosts:
1.2.3.4 spock kirk mccoy

Then the machine can be referenced by any of those 3 names.
Jeff_Traigle
Honored Contributor

Re: Changing Host Name

You *can*, but it's not a simple one step thing to do...

You need to do the following at a minimum:

* hostname
* uname -S
* Edit /etc/rc.config.d/netconf so the change will exist after reboot
* Edit /etc/hosts to make the change there too
* Make sure DNS or NIS entries get updated too if you use any of those

Best to reboot as SAM would have you do.
--
Jeff Traigle