PDA

View Full Version : [ubuntu] Sudo


DeMus
May 25th, 2008, 03:12 PM
Hi,

Everytime when I use sudo in a terminal I get the following message:

jan@2-Quad:~$ sudo ls -l
sudo: unable to resolve host 2-Quad
[sudo] password for jan:

ls -l is just an example instruction.
I gave my computer the name 2-Quad, so that's the host name. But what does the message mean and how can I make it go away? I don't see that something is not working, I just get the message. Can somebody tell me what is wrong, where it is wrong and how to change it?

Thanks,
DeMus

HalPomeranz
May 25th, 2008, 03:23 PM
The error message means that the system is unable to translate your system's hostname into an IP address. The easiest way to fix this is to update your /etc/hosts file. Find a line that looks like:

127.0.0.1 localhost.localdomain localhost

Change it to

127.0.0.1 localhost.localdomain localhost 2-Quad

That should make the error go away.

molotov00
May 25th, 2008, 10:54 PM
That seems like a wierd error. Do we know why it happened to him? Seems like something that shouldn't happen. Bug?

M

HalPomeranz
May 25th, 2008, 11:50 PM
That seems like a wierd error. Do we know why it happened to him? Seems like something that shouldn't happen. Bug?

If the original poster changed the system hostname after the initial install, it seems possible to me that the hostname may not have been propagated to all necessary system files. I'm not sure I'd call it a bug until I know exactly how the hostname change was done.

DeMus, can you describe exactly how you changed the name of your machine?

chrisccoulson
May 26th, 2008, 11:24 AM
Could be related to https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/185209

DeMus
May 27th, 2008, 12:22 AM
The error message means that the system is unable to translate your system's hostname into an IP address. The easiest way to fix this is to update your /etc/hosts file. Find a line that looks like:

127.0.0.1 localhost.localdomain localhost

Change it to

127.0.0.1 localhost.localdomain localhost 2-Quad

That should make the error go away.

I don't know why but it worked. Thanks for the help. Can you also explain it to me?

DeMus

HalPomeranz
May 27th, 2008, 01:02 AM
I don't know why but it worked. Thanks for the help. Can you also explain it to me?

Sure. The problem was that there was no configuration on your system to allow it to convert your machine's hostname into an IP address. That's what the error message "unable to resolve host 2-Quad" means-- to "resolve" a host means to convert that name into an IP.

Name resolution can happen in any one of several ways. On many networks you use DNS for name resolution, but there's also networked databases such as LDAP and NIS. Failing that, you can use /etc/hosts files, which is what I had you configure here.

Each line in the /etc/hosts file lists an IP address and one or more host names associated with that IP. All I told you to do was to add your machine's hostname to the /etc/hosts entry for the loopback interface (127.0.0.1). sudo doesn't care which interface IP it gets when trying to resolve your hostname, just that it gets something as a result of the lookup. Once you added the name to a valid entry in the /etc/hosts file, sudo was satisfied and stopped throwing the error.

DeMus
May 27th, 2008, 01:59 PM
If the original poster changed the system hostname after the initial install, it seems possible to me that the hostname may not have been propagated to all necessary system files. I'm not sure I'd call it a bug until I know exactly how the hostname change was done.

DeMus, can you describe exactly how you changed the name of your machine?

No, I can not. It must have happened when I tried to install and configure Samba, but I can not tell you anymore what I had to do to make Samba work. I'm sorry.

DeMus