Sudo: unable to resolve hostname

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post please read this

Sudo: unable to resolve hostname

Postby perrybucsdad on Thu Sep 27, 2012 11:00 am

I had to change the host name of my computer, and did this in /etc/hostname using

Code: Select all
sudo vi /etc/hostname


I rebooted and all appeared fine until I needed to run a sudo command. The command will run, and it says that it is unable to resolve the hostname now. I did some checking and it says that I need to make sure I also modify the /etc/hosts file to include the new host name. Below is my host file.

Code: Select all
127.0.0.1       localhost
127.0.1.1       sam-linux

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
~                       


Sam-linux is the new host, and it is below localhost, but still generates the error message. What else am I missing?? Is the IP address correct for sam-linux? The actual IP will vary each time I log into a different network but in some of the examples, I have seen 127.0.0.6, others 127.0.0.1... so I'm not sure what it should be.

Thanks,

John
perrybucsdad
Level 1
Level 1
 
Posts: 9
Joined: Mon Sep 24, 2012 5:08 pm

Linux Mint is funded by ads and donations.
 

Re: Sudo: unable to resolve hostname

Postby altair4 on Thu Sep 27, 2012 1:57 pm

What you have here looks right for /etc/hosts:
127.0.0.1 localhost
127.0.1.1 sam-linux

As long as sam-linux is exactly the same as the content of /etc/hostname. You rebooted after you changed /etc/hostname. Did you reboot after you changed /etc/hosts?
Is the IP address correct for sam-linux?

Yes, the 127.0.1.1 is a made up ip address that's there to insure your system will resolve to a fully qualified hostname internally.

The odd part of your post is this:
The actual IP will vary each time I log into a different network but in some of the examples, I have seen 127.0.0.6, others 127.0.0.1

Those are all loopback ip addresses. That's the ip address your system has when it's not connected to any kind of network and not getting an ip address from DHCP. If you connect directly to your ISP then you will have a public ip address that the ISP assigns to you. But if you connect to a router then you should have a private ip address that starts with one of these:
10.x.x.x
172.16.x.x
192.168.x.x

So I don't quite know what's going on there.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 16
Level 16
 
Posts: 6083
Joined: Tue Feb 03, 2009 10:27 am

Re: Sudo: unable to resolve hostname

Postby perrybucsdad on Thu Sep 27, 2012 2:51 pm

I tried something. I changed the hostname to "SamLinux" (I removed the dash), and everything seems fine now. How odd. The strange thing is the orig hostname had a dash in it as well and all was fine. I thought the dash ( "-" ) was allowed and were allowed in the naming rules. That is really odd. I really would prefer to have the dash, but I can live with it I guess.
perrybucsdad
Level 1
Level 1
 
Posts: 9
Joined: Mon Sep 24, 2012 5:08 pm


Return to Other topics

Who is online

Users browsing this forum: No registered users and 5 guests