RE: Fedora core 2 and hostname

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 19 Jun 2004, VIKAS B wrote:

> Hi Brian,
>   Yes there's an easy way of changing the hostname in FC2.
> after Login just at command line enter 'hostname' to see what is the 
> hostname seted there, if returns localhost then you have to change this in
> 
> 1.  '/etc/sysconfig/network' edit this file and give hostname whatever you 
> like in the line "hostname=" and then save this file and at the command line 
> give the hostname command but now also you will get the same old host name 
> as 'localhost' so set the hostname using command hostname (for eg: hostname 
> vikas --  here hostname command will set the hostname as vikas, pls note 
> that the name you are giving for the host name must be same as the hostname 
> you have specified in '/etc/sysconfig/network' file.

No, it does not have to be the same. It is just that if it is different, then
what is in /etc/sysconfig/network will be the hostname when you reboot.
The hostname you set on the command line will be gone. If you are going
to reboot then messing with the hostname command is a waste of time.

At boot time the initscripts read the hostname from /etc/sysconfig/network
and set it to whatever the HOSTNAME variable is set to. Note the HOSTNAME=
line in the above file must be uppercase. ie: HOSTNAME=foo will set the
hostname to foo. hostname=foo will not.

> 2.  '/etc/hosts' edit this file and this file would look like
>         " IPAddress   hostname  localhost.localdomain  localhost"
> in the place of hostname give the name as you wish(in the example same as 
> hostname given in /etc/sysconfig/network file and hostname setted at command 
> line), and save this file

If you have a working dns on the network and the new name resolves you do not
need to mess with /etc/hosts. If you are going to mess with /etc/hosts leave
the line with the localhost stuff in it and add another line with the new
info. That way localhost will always resolve no matter what. Not having
localhost resolve can cause problems sometimes.

> 3. Now restart the NFS and Network service by using the command 'service nfs 
> restart' and
> 'service network restart'

Why? This is not necessary, especially if you are going to reboot. What is the
point of restarting a service and then rebooting the machine to restart the
service again. It appears to me you are giving advice on a subject you know
little about.

> 4. Restart your computer inorder to take effect the  changes you have done.

Not necessary. Pick one way or the other. If you are going to restart the machine
simply edit /etc/sysconfig/network and /etc/hosts if necessary, then reboot.

If you do not want to reboot, then do the above plus "hostname new_hostname"
and "service syslog restart" so that syslog rereads the hostname and labels
the log files correctly. The OP wanted a simple way to change the hostname.

Your way while it will not hurt is unnecessarily complex and as you described
it above will not work (hostname= != HOSTNAME=).


HTH,

Tom



[Index of Archives]     [Red Hat General]     [CentOS Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux