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!
Nilantha
--------------------------------------------------------
"An expert is a person who has made all the mistakes
that can be made in a very narrow field." - Neils Bohr
--------------------------------------------------------
> just write whatever hostname you want in the /etc/hostname file!!!!! that's all
> dude!!
Dude, you did't tell him that the change doesn't take effect until the
next boot.
--
Fran
BTW, in my current Red Hat Linux, there is no /etc/hostname.
Its only /etc/hosts.
> Hi,
> I had tried all that..and it didnt work. So I had to put a query here.
> I had even rebooted the machine after modifying /etc/hosts/.
>
> BTW, in my current Red Hat Linux, there is no /etc/hostname.
> Its only /etc/hosts.
>
IIRC, go edit /etc/sysconfig/network. At reboot, RedHat reads the HOSTNAME
param written in there and rewrites /etc/hostname.
--
SF
Games are very educational. Scrabble teaches us vocabulary, Monopoly teaches
us cash-flow management, and Dungeons & Dragons teaches us to loot dead bodies.
NS
--------------------------------------------------------
"An expert is a person who has made all the mistakes
that can be made in a very narrow field." - Neils Bohr
--------------------------------------------------------
NS
> sorry man... I only noticed that once I clicked "send"!!! I didn't want
> to write it in another post and I thought he'd be smart enough to try a
> reboot if he didn't notice the change immediately! anyway.. reboot is
> not necessary... you can change your runlevel to 1 (depends on the
> distro though! I'm using Debian etch) and change it back to whatever
> runlevel you want...
"hostname --file /etc/hostname" will be sufficient, no need to reboot.
Btw, now that you mention Debian: /etc/hostname is a Debian-specific thing.
This file is nowhere standardised, other distributions are free to read the
hostname from whatever file they want. Gentoo for instance
uses /etc/conf.d/hostname. /etc/hostname doesn't exist there, and is just
ignored by the init scripts if created. Other distributions use different
files, RedHat and Suse have these settings under /etc/sysconfig, to give
another example.
Summarizing, you can't set the hostname permanently in a
platform-independent way.
Anyway its not a good idea to mingle in configuration files without the user
being involved. This happening on production systems can have bad
consequences to the functionality of the network and the mood of the
responsible admins ;)
--
Freedom is always the freedom of dissenters.
(Rosa Luxemburg)
/etc/hostname is not a Debian invention. It comes from Unix (though it has
now grown suffixes there).
--
John Hasler
jo...@dhh.gt.org
Dancing Horse Hill
Elmwood, WI USA
> Sebastian writes:
>> Btw, now that you mention Debian: /etc/hostname is a Debian-specific
>> thing.
>
> /etc/hostname is not a Debian invention. It comes from Unix (though it
> has now grown suffixes there).
Thanks for the correction. I just assume, that it was Debian-specific,
since it's the only linux distribution, if seen this file on.
In article <g3rr3d$jb4$02$1...@news.t-online.com>,
Sebastian \"lunar\" Wiesner <basti....@gmx.net> wrote:
>John Hasler <jo...@dhh.gt.org>:
>
>> Sebastian writes:
>>> Btw, now that you mention Debian: /etc/hostname is a Debian-specific
>>> thing.
>>
>> /etc/hostname is not a Debian invention. It comes from Unix (though it
>> has now grown suffixes there).
>
>Thanks for the correction. I just assume, that it was Debian-specific,
>since it's the only linux distribution, if seen this file on.
SuSE:
/etc/HOSTNAME
SunOS-5.8:
/etc/hostname.<interface>
In both cases:
ls -l /etc/hostname
ls: cannot access /etc/hostname: No such file or directory
The user uses RedHat (whatever version) and I think it's much easier to
google for something like 'redhat set hostname' instead of getting a lot
of useless hints which might only with specific systems (including
all unix-derivates like SunOS, IRIX, SINIX, .....).
A quick google-search leads to /etc/sysconfig/network for RedHat.
The file /etc/sysconfig/network does not exist on SuSE and SunOS-5.8 which
naturally leads to the conclusion that neither /etc/hostname nor
/etc/sysconfig/network are standardised on any unix-clone.
If someone wants more detailed information about the setting of the
hostname, something like this might help (SuSE as an example):
# fgrep -i hostname /etc/init.d/*
[....]
/etc/init.d/boot.localnet:# Description: setup hostname and yp
/etc/init.d/boot.localnet: # set hostname and domainname
/etc/init.d/boot.localnet: XHOSTNAME=""
/etc/init.d/boot.localnet: test -f /etc/HOSTNAME && {
/etc/init.d/boot.localnet: XHOSTNAME=`cat /etc/HOSTNAME`
/etc/init.d/boot.localnet: test -n "$XHOSTNAME" && {
/etc/init.d/boot.localnet: echo -n Setting up hostname \'${XHOSTNAME%%.*}\'
/etc/init.d/boot.localnet: hostname ${XHOSTNAME%%.*}
[......]
It's trivial:
if /etc/HOSTNAME exists and is not empty then set the hostname
without domain attached.
regards
winfried
--
Winfried Magerl - Internet Administration
Siemens IT Solutions and Services, 81739 Munich, Germany
Internet-Mail: winfrie...@siemens.com
NS
--------------------------------------------------------
"An expert is a person who has made all the mistakes
that can be made in a very narrow field." - Neils Bohr
--------------------------------------------------------
Threads drift. The OP's problem ceased to be the subject of the
discussion.
Nilantha Silva writes:
> So, in other words... if you create the file (if it doesn't exist) will
> solve the problem... and wasn't that what I was saying???????????????? it
> seems to me that dude doesn't have common sense...(no offense) if the
> file doesn't exist, and somebody tells you that file is used to set the
> hostname, why not create it and see what happens?
If his distribution doesn't use the file creating it will have no effect.
BTW please don't top post.
Jerry
sorry man, I'm new to this usenet thing.... I just thought this'll be a
good place to share what I know and learn something new... that's why I
started to post on newsgroups... I really didn't know there was a
certain protocol when replying to posts.. Won't happen again!
Well... back to the subject, if his distro doesn't use the /etc/hostname
file, he can always make the distro use it can't he? by modifying the
proper runlevel script or by creating a new "S" script in the proper
runlevel???? that has to work..... given that his hostname command works!
> I am trying to change the host name of a linux machine.
man hostname
Ciao...
He could do that, and do it again after he upgrades (or patches) his
system, and do it again when he upgrades again...
Better to learn how his disto sets the hostname and use that
mechanism.
Doug
I guess you're right... but that said, he can write his own "S" script
and reuse it every time he needs to..... that's an option.. cuz the
original question was that he couldn't get his distro to set the
hostname using its methods right... and if the original writer of this
post still reads these replies, it'll be nice if you can tell us which
version of RedHat you're using...
He would also have to find the right timing to start the script. Too
early and the distro's scripts will overwrite the hostname. Too late
and you might have network services start that base some info on the
hostname (apache comes to mind).
If the OP runs out of man pages to read (or just doesn't read them), he
can try
find /etc -type f -exec grep hostname {} /dev/null \;
for hints as to where the hostname is set on his system.
Doug