Operating System - HP-UX
1830503 Members
2647 Online
110006 Solutions
New Discussion

Novice Question /etc/hosts

 
Chris Brown_20
Occasional Contributor

Novice Question /etc/hosts

Hi There,
I'm having the common "The Desktop Messaging System Could Not Be Started" problem. Reading the threads it looks like I should check the /etc/hosts file contents are correct.

I can get into falesafe mode. And I can get into the etc directory. And using the ls command I can see the hosts file. But I have no idea how to display the contents or edit them.....Any hints on how I do that?

Cheers
Phil
15 REPLIES 15
Chris Wilshaw
Honored Contributor

Re: Novice Question /etc/hosts

To check the contents of the file, use either

cat /etc/hosts

or

more /etc/hosts

To edit the file

vi /etc/hosts
Simon Hargrave
Honored Contributor

Re: Novice Question /etc/hosts

Hi

You can list the contents of the file with the "cat" command: -

cat /etc/hosts

To edit the file, you need to use the "vi" command. However I recommend you read up on "vi" commands before you do, as it's not intuitive for the beginner.

Before you try and edit the file, take a copy with the command: -

cp /etc/hosts /etc/hosts.backup

So if you do break it you can recover it.

There's a basic intro to vi here: -

http://www.msn.fullfeed.com/faq/vi.help

Have fun!
Franky_1
Respected Contributor

Re: Novice Question /etc/hosts

Hi,

to look at the contents just type

cat or more (scroll)

and to edit type

vi

Regards

Franky
Don't worry be happy
Robert-Jan Goossens
Honored Contributor

Re: Novice Question /etc/hosts

Hi Phil,

First mount your filesytems,

# mount -a

now you can use vi or more to view your /etc/hosts file.

Regards,
Robert-Jan
Chris Brown_20
Occasional Contributor

Re: Novice Question /etc/hosts

Thanks for the info so far! I have looked in the /etc/hosts file and there are 3 entries.

192.168.0.1 coms.mshome.net coms
192.168.0.125 hpunix hpunix
127.0.0.1 localhost loopback

hpunix is the name I entered for the system, and I can ping the ip address (192.168.0.125), but I cant ping the name or the alias (both hpunix). Originally there was no alias but I entered it to see if that was the problem.

Considering the hosts file looks ok any idea what else could be causing the "The Desktop Messaging System Could Not Be Started" message?

Thanks
Phil
Dave Olker
Neighborhood Moderator

Re: Novice Question /etc/hosts

Hi Chris,

If you're using /etc/hosts for your hostname resolution, make sure your /etc/nsswitch.conf file is configured to look there for the information:

hosts: files

Once you put this nsswitch.conf file in place, what does an nslookup of the hostname or alias return?

Regards,

Dave


I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
Sundar_7
Honored Contributor

Re: Novice Question /etc/hosts

Hi Phil,

By default the name resolution policy in HP-UX is

DNS [NOTFOUND=return UNAVAIL=continue]

So if you have /etc/resolv.conf, when you ping hpunix, only your DNS is checked and not /etc/hosts file.

Add the following entries in /etc/nsswitch.conf file

# vi /etc/nsswitch.conf
hosts: dns [ NOTFOUND=continue UNAVAIL=continue SUCCESS=return] hosts

Now you should be able to ping hpunix and possibly your CDE will start working again.

- Sundar.
Learn What to do ,How to do and more importantly When to do ?
Dave Olker
Neighborhood Moderator

Re: Novice Question /etc/hosts

Hi Sundar,

I think instead of:

hosts: dns [ NOTFOUND=continue UNAVAIL=continue SUCCESS=return] hosts

you meant to say:

hosts: dns [ NOTFOUND=continue UNAVAIL=continue SUCCESS=return] files

I'm sure this is what you meant, but I get nervous about people cutting/pasting stuff from ITRC into their actual files and then having things behave strangely. :)

This is similar to my suggestion of just stripping out all the DNS/NIS/LDAP stuff and just going straight to the /etc/hosts file:

hosts: files

That way the library routines don't spend any time calling the NSS_DNS routines only to find that DNS isn't configured and then falling back to NSS_FILES lookups.

If DNS is configured on the system then I agree with your nsswitch.conf syntax. If it's not, and there are no plans to implement DNS, then it's a bit faster to avoid calling the NSS_DNS library routines every time a hostname or IP address lookup request is processed.

Regards,

Dave


I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
Sundar_7
Honored Contributor

Re: Novice Question /etc/hosts

Hi Dave,

Yes , sorry this is what I intended to mention

hosts: dns [ NOTFOUND=continue UNAVAIL=continue SUCCESS=return] files

But, correct me if I am wrong Dave, but I believe he has resolver configured. If not, his attempt to ping hpunix should have succeeded ?

By default, if there is no nsswitch.conf and if there is no /etc/resolv.conf file then /etc/hosts will be used.

He has mentioned, he is not able to ping using /etc/hosts, so I assume he has /etc/resolv.conf file configured.

Am I missing something here ?

-- Sundar.
Learn What to do ,How to do and more importantly When to do ?
Dave Olker
Neighborhood Moderator

Re: Novice Question /etc/hosts

Hi Sundar,

After spending 8 years in WTEC, I've become conditioned to assume nothing about a customer's environment. :)

You are probably correct about an existing resolv.conf, but that doesn't mean the information in the resolv.conf file is accurate or intentional. I've worked on numerous cases where customers said "we're not using DNS" and then I'd show them their /etc/resolv.conf file and ask them why it was there and they'd say "no idea...one of the other administrators must have copied it from a different system..." or something like that.

In any case, if DNS is being used then I agree with your syntax. If DNS is not being used then I'd bypass DNS in the nsswitch.conf file and just go to /etc/hosts.

Regards,

Dave


I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
Sundar_7
Honored Contributor

Re: Novice Question /etc/hosts

Dave,

We are not assuming anything here :-). If there is no /etc/resolv.conf, then he SHOULD be able to ping using the host name entry in /etc/hosts file. He is unable to now, so I am very positive that he has /etc/resolv.conf file configured.
Learn What to do ,How to do and more importantly When to do ?
Muthukumar_5
Honored Contributor

Re: Novice Question /etc/hosts

It may be your reverse lookup problem.
when ever you get problem on hosts then troubleshoot as,

check /etc/nsswitch.conf file's hosts: entry and

/etc/resolve.conf -- dns
/etc/hosts.conf -- hosts

that will be the key and check hostname with nslookup / nsquery commands

Check this thread for discussions on this,
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=624370
Easy to suggest when don't know about the problem!
Chris Brown_20
Occasional Contributor

Re: Novice Question /etc/hosts

Ok thanks guys! I've got the CDE working now...Yay!
Franky_1
Respected Contributor

Re: Novice Question /etc/hosts

Hi,

if you got it working ... then just assign points to the people who helped you in doing so

Regards

Franky
Don't worry be happy
Sundar_7
Honored Contributor

Re: Novice Question /etc/hosts

Chris, Would you care to let us know what solved your problem ?
Learn What to do ,How to do and more importantly When to do ?