How to change the hostname in linux - Networking

This is a discussion on How to change the hostname in linux - Networking ; 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 ## /etc/nsswitch.conf is modified as follows : #hosts: db files nisplus nis dns ##hosts: files nisplus dns ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: How to change the hostname in linux

  1. How to change the hostname in linux

    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>


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


    /etc/sysconfig/network
    ##HOSTNAME=
    HOSTNAME=

    Then I have executed these on the shell :
    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!


  2. Re: How to change the hostname in linux

    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>
    >
    >
    > /etc/nsswitch.conf is modified as follows :
    > #hosts: db files nisplus nis dns
    > ##hosts: files nisplus dns
    > hosts: files
    >
    >
    > /etc/sysconfig/network
    > ##HOSTNAME=
    > HOSTNAME=
    >
    > Then I have executed these on the shell :
    > hostname


    If /etc/sysconfig/network controls hostname then running
    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.

  3. Re: How to change the hostname in linux

    On Jun 23, 6:16*am, guddu 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>
    >
    >
    > /etc/nsswitch.conf is modified as follows :
    > #hosts: * * db files nisplus nis dns
    > ##hosts: * * *files nisplus dns
    > hosts: * * *files
    >
    > /etc/sysconfig/network
    > ##HOSTNAME=
    > HOSTNAME=
    >
    > Then I have executed these *on the shell :
    > 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

  4. Re: How to change the hostname in linux

    guddu 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>
    >
    >
    > /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=
    > HOSTNAME=
    >
    > Then I have executed these on the shell :
    > 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 hemphill@alumni.caltech.edu
    "This isn't flying. This is falling, with style." -- Buzz Lightyear

+ Reply to Thread