sudo -i warning.

Sep 26, 2023 Last reply: 2 years ago 5 Replies

When I type sudo -i on my Rpi it works but I get the following warning..



"sudo: Unable to resolve host intranet-pihole2: Name or service not known."



Anyone give a clue why I get that?



Yes this is a spare machine used as a backup for my pihole and intranet pi.



Thanks.



Bob.


Look in /etc/hosts and /etc/hostname Does that name exist?

Thanks.

Yes. It exists in /etc/hostname but not in /etc/hosts.

It is the network name of the machine it is running on.

I presume nasty things will happen if I delete it?

Bob.

I think they already have

My /etc/host looks like this

$ more /etc/hosts

127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters 127.0.1.1 heating-controller

You need to make yours look similar but with 'heating-controller' replaced with 'intranet-pihole'.

Oh right, that's interesting. The /etc/host file had much the same as yours except the network name was original and so when I changed the name using raspi-config last week, it failed to change the name there but it did change on the network.

Anyway just put it right and it has fixed the issue.

Thanks TNP & Chris.

Cheers,

Bob.

Is it necessary to have entries in /etc/hosts for any computers that the Pi needs to talk to? On a bog-standard home network (TPlink router with DHCP enabled) a Pi can ping other Linux or Windows PCs by their hostname: the router handles the name-to-IP resolution. That doesn't work for Windows PCs - a Pi can ping a Windows computer, but a Windows PC cannot *reliably* ping a Pi by hostname. But that is solved by using appending ".local" to the Pi's hostname when accessing from Windows.

When I refer to pinging, I include all other things like Windows accessing a SAMBA shared drive on the Pi (*), or a browser on Windows accessing an HTTP server on the Pi. So I changed "http://pi:1234" to "http://pi.local:1234" in any browser bookmarks and it worked fine. Easier than having to use IP addresses in URLs.

(*) OK, that uses NetBIOS so the name query mechanism is different to a simple ping or a URL reference.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required