Networking Forums

Networking Forums > Computer Networking > Linux Networking > How to change the hostname in linux

Reply
Thread Tools Display Modes

How to change the hostname in linux

 
 
guddu
Guest
Posts: n/a

 
      06-23-2008, 05:16 AM
Hi,
I am trying to change the host name of a linux machine.
I have modified /etc/hosts as follows :

127.0.0.1 localhost.localdomain localhost
##< IP ADDRESS> <OLD HOSTNAME>
<IP ADDRESS> <NEW HOSTNAME>

/etc/nsswitch.conf is modified as follows :
#hosts: db files nisplus nis dns
##hosts: files nisplus dns
hosts: files


/etc/sysconfig/network
##HOSTNAME=<OLD_HOSTNAME>
HOSTNAME=<NEW_HOSTNAME>

Then I have executed these on the shell :
hostname <new_HOSTNAME>

service xinetd restart


After executing these steps, my machine is not taking the new
hostname.
If I execute
#hostname

I get hostname as (none)

Can anyone tell me what is that which I am missing here.

Thanks in Advance!

 
Reply With Quote
 
 
 
 
Bit Twister
Guest
Posts: n/a

 
      06-23-2008, 07:40 AM
On Sun, 22 Jun 2008 22:16:59 -0700 (PDT), guddu wrote:
> Hi,
> I am trying to change the host name of a linux machine.


With 300+ linux distributions, you may want to read
http://www.catb.org/~esr/faqs/smart-questions.html

Always helps to provide which distribution, version and maybe which
desktop manager you are running. Those may get you more detailed
answers to your problem.

> I have modified /etc/hosts as follows :
>
> 127.0.0.1 localhost.localdomain localhost
> ##< IP ADDRESS> <OLD HOSTNAME>
><IP ADDRESS> <NEW HOSTNAME>
>
> /etc/nsswitch.conf is modified as follows :
> #hosts: db files nisplus nis dns
> ##hosts: files nisplus dns
> hosts: files
>
>
> /etc/sysconfig/network
> ##HOSTNAME=<OLD_HOSTNAME>
> HOSTNAME=<NEW_HOSTNAME>
>
> Then I have executed these on the shell :
> hostname <new_HOSTNAME>


If /etc/sysconfig/network controls hostname then running
hostname <new_HOSTNAME>
should have no impact on next reboot. Then again, you may have just
overrode normal operation of assigning hostname during boot.


> service xinetd restart


That should have not modified anything. If /etc/sysconfig/network controls
hostname, then restarting the network might change it, might not.

Anytime I change a host name, I reboot so that all services depending
on the name will be restarted.

> Can anyone tell me what is that which I am missing here.


Not me, without know exactly which distribution you are running.

I recommend a reboot based lack of information provided.
 
Reply With Quote
 
Artur Kaminski
Guest
Posts: n/a

 
      06-23-2008, 08:14 AM
On Jun 23, 6:16*am, guddu <visha...@gmail.com> wrote:
> Hi,
> I am trying to change the host name of a linux machine.
> I have modified /etc/hosts as follows :
>
> 127.0.0.1 localhost.localdomain localhost
> ##< IP ADDRESS> <OLD HOSTNAME>
> <IP ADDRESS> <NEW HOSTNAME>
>
> /etc/nsswitch.conf is modified as follows :
> #hosts: * * db files nisplus nis dns
> ##hosts: * * *files nisplus dns
> hosts: * * *files
>
> /etc/sysconfig/network
> ##HOSTNAME=<OLD_HOSTNAME>
> HOSTNAME=<NEW_HOSTNAME>
>
> Then I have executed these *on the shell :
> hostname <new_HOSTNAME>
>
> service xinetd restart
>
> After executing these steps, my machine is not taking the new
> hostname.
> If I execute
> #hostname
>
> *I get hostname as (none)
>


I have a procedure which always works:
hostname new_hostname
hostname > /etc/hostname


Regards
Artur
 
Reply With Quote
 
Scott Hemphill
Guest
Posts: n/a

 
      06-23-2008, 12:24 PM
guddu <(E-Mail Removed)> writes:

> Hi,
> I am trying to change the host name of a linux machine.
> I have modified /etc/hosts as follows :
>
> 127.0.0.1 localhost.localdomain localhost
> ##< IP ADDRESS> <OLD HOSTNAME>
> <IP ADDRESS> <NEW HOSTNAME>
>
> /etc/nsswitch.conf is modified as follows :
> #hosts: db files nisplus nis dns
> ##hosts: files nisplus dns
> hosts: files


Unless all the Internet and local host names you need are stored in
/etc/hosts, this won't work very well.

I suggest:

hosts: files dns

> /etc/sysconfig/network
> ##HOSTNAME=<OLD_HOSTNAME>
> HOSTNAME=<NEW_HOSTNAME>
>
> Then I have executed these on the shell :
> hostname <new_HOSTNAME>
>
> service xinetd restart
>
>
> After executing these steps, my machine is not taking the new
> hostname.
> If I execute
> #hostname
>
> I get hostname as (none)
>
> Can anyone tell me what is that which I am missing here.


It's hard to say. What Linux distribution have you installed?

Scott
--
Scott Hemphill (E-Mail Removed)
"This isn't flying. This is falling, with style." -- Buzz Lightyear
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hostname change G2 Linux Networking 9 12-18-2003 02:28 PM
change hostname faeychild Linux Networking 9 11-01-2003 03:10 PM
Hostname change made my Linux box go crazy! Please, help. N.K. Linux Networking 3 08-15-2003 10:01 AM
Can't change the f*@&#ing hostname in RedHat 9 Tron Thomas Linux Networking 2 08-10-2003 11:41 PM
Re: How to change hostname? Xyerp Linux Networking 0 07-04-2003 09:17 AM



1 2 3 4 5 6 7 8 9 10 11