[SOLVED] sudo: unable to resolve host charlie-ThinkPa

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
cmtuck
Level 1
Level 1
Posts: 6
Joined: Thu Jun 13, 2019 3:17 pm
Location: Vancouver, BC Canada

[SOLVED] sudo: unable to resolve host charlie-ThinkPa

Post by cmtuck » Thu Jun 13, 2019 3:35 pm

I am unable to enter my password in the terminal window. It will not accept anything, never mind my password.

Here is where I am at:
charlie@charlie-ThinkPa ~ $ sudo dpkg -i /downloads/nordvpn-release_1.0.0_all.deb
sudo: unable to resolve host charlie-ThinkPa
[sudo] password for charlie:

any help would be greatly appreciated.
Last edited by cmtuck on Sun Jun 16, 2019 2:23 am, edited 1 time in total.

User avatar
karlchen
Level 20
Level 20
Posts: 10714
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: sudo: unable to resolve host charlie-ThinkPa

Post by karlchen » Thu Jun 13, 2019 3:55 pm

Hello, cmtuck.

I googled for the error message "sudo: unable to resolve host". Google returned a number of hits. I picked one of them, which reminded me what the cause for this error is: Error message “sudo: unable to resolve host (none)”
Your computername charlie-ThinkPa is used in 2 files, /etc/hostname (defines the name) and /etc/hosts (assigns IP 127.0.1.1 addresses to it).
The computername, hostname in Linux terms, has to be specified in both files in exactly the same way. Else the error will occur, which you encountered.
  • Please, open a terminal window.
  • Execute the commandline cat /etc/hostname.
    Copy the commandline and the output, which it displays and paste it into your next reply.
  • Next execute the commandline cat /etc/hosts.
    Copy the commandline and the output, which it displays and paste it into your next reply.
I assume that there will be an inconcistency between the 2 files with respect to your hostname (computername).

Best regards,
Karl
Image
Linux Mint 18.1 64-bit Cinnamon Desktop, Total Commander 9.22a 64-bit
Ubuntu 18.04.2 32-bit Mate Desktop, Total Commander 9.22a 32-bit
Windows? - 1 window in every room

cmtuck
Level 1
Level 1
Posts: 6
Joined: Thu Jun 13, 2019 3:17 pm
Location: Vancouver, BC Canada

Re: sudo: unable to resolve host charlie-ThinkPa

Post by cmtuck » Fri Jun 14, 2019 3:54 pm

Karl,
see below:

Code: Select all

charlie@charlie-ThinkPa ~ $ cat /etc/hostname
charlie-ThinkPa

Code: Select all

charlie@charlie-ThinkPa ~ $ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 charlie-ThinkPad-SL500.home

# 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

Thanks for your assistance
charlie@charlie-ThinkPa ~ $

User avatar
karlchen
Level 20
Level 20
Posts: 10714
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: sudo: unable to resolve host charlie-ThinkPa

Post by karlchen » Fri Jun 14, 2019 4:21 pm

Hello, cmtuck.

As can be seen the file /etc/hostname defines your hostname as charlie-ThinkPa.
In the file /etc/hosts line 2, however, the hostname is given as charlie-ThinkPad-SL500.home.

Quite obviously, the 2 names are not identical.
I wonder a bit where the suffixed pseudo domain .home comes from.

I suggest to change the hostname to read charlie-ThinkPad in both files. Drop the .home suffix from /etc/hosts. Preserve capitalization (upper case and lower case letters).
Then reboot the machine.

Commands to edit the 2 files with root privileges:
xed admin:///etc/hostname
xed admin:///etc/hosts

In case the 2 commands should fail for the same reason as the sudo command, in this case you may have to boot your machine from a Mint live system, mount the root filesystem on the harddisk inside the live system and edit the 2 files from there.

Regards,
Karl
Image
Linux Mint 18.1 64-bit Cinnamon Desktop, Total Commander 9.22a 64-bit
Ubuntu 18.04.2 32-bit Mate Desktop, Total Commander 9.22a 32-bit
Windows? - 1 window in every room

cmtuck
Level 1
Level 1
Posts: 6
Joined: Thu Jun 13, 2019 3:17 pm
Location: Vancouver, BC Canada

Re: sudo: unable to resolve host charlie-ThinkPa

Post by cmtuck » Fri Jun 14, 2019 5:39 pm

Karl,
this is what i get when trying to edit the two files:

Code: Select all

charlie@charlie-ThinkPa ~ $ xed admin:///etc/hostname

** (xed:12123): WARNING **: The specified location is not supported
charlie@charlie-ThinkPa ~ $ xed admin:///etc/hostname

** (xed:12190): WARNING **: The specified location is not supported
charlie@charlie-ThinkPa ~ $ xed admin:///etc/hosts

** (xed:12227): WARNING **: The specified location is not supported

User avatar
karlchen
Level 20
Level 20
Posts: 10714
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: sudo: unable to resolve host charlie-ThinkPa

Post by karlchen » Fri Jun 14, 2019 6:27 pm

Hi, cmtuck.

Could you, please, try
pkexec xed /etc/hostname
pkexec xed /etc/hosts
instead.

Regards,
Karl
Image
Linux Mint 18.1 64-bit Cinnamon Desktop, Total Commander 9.22a 64-bit
Ubuntu 18.04.2 32-bit Mate Desktop, Total Commander 9.22a 32-bit
Windows? - 1 window in every room

cmtuck
Level 1
Level 1
Posts: 6
Joined: Thu Jun 13, 2019 3:17 pm
Location: Vancouver, BC Canada

Re: sudo: unable to resolve host charlie-ThinkPa

Post by cmtuck » Sat Jun 15, 2019 4:52 pm

Hi Karl,
this is the result:

charlie@charlie-ThinkPa ~ $ pkexec xed /etc/hostname
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused

(xed:3151): Gtk-WARNING **: cannot open display:
charlie@charlie-ThinkPa ~ $ pkexec xed /etc/hosts
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused

Charlie

User avatar
WharfRat
Level 21
Level 21
Posts: 12897
Joined: Thu Apr 07, 2011 8:15 pm

Re: sudo: unable to resolve host charlie-ThinkPa

Post by WharfRat » Sat Jun 15, 2019 5:09 pm

gksudo xed /etc/hosts should work.
ImageImage

cmtuck
Level 1
Level 1
Posts: 6
Joined: Thu Jun 13, 2019 3:17 pm
Location: Vancouver, BC Canada

Re: sudo: unable to resolve host charlie-ThinkPa

Post by cmtuck » Sat Jun 15, 2019 5:54 pm

this is the result:

127.0.0.1 localhost
127.0.1.1 charlie-ThinkPad-SL500.home

# 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

Do I change the name here and then do the same thing with
gksudo xed /etc/hostname?

User avatar
WharfRat
Level 21
Level 21
Posts: 12897
Joined: Thu Apr 07, 2011 8:15 pm

Re: sudo: unable to resolve host charlie-ThinkPa

Post by WharfRat » Sat Jun 15, 2019 5:59 pm

You would want them the same so yes.
ImageImage

User avatar
karlchen
Level 20
Level 20
Posts: 10714
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: sudo: unable to resolve host charlie-ThinkPa

Post by karlchen » Sat Jun 15, 2019 6:07 pm

gksudo xed /etc/hosts should work.
Only if the Mint version is 18.x. On 19.x gksudo no longer exists.
sudo fails, pkexec fails, why should gksudo not fail?

I think we should give recovery mode -> root shell a try, because we will have the root privileges, which we need.
Editor nano will be available, which we can use to edit the 2 files /etc/hostname and /etc/hosts.

So the suggested steps are:
  1. Reboot Linux Mint
  2. As soon as the machine starts rebooting, press the <Shift> key in order to bring up the Grub boot menu.
    Note:
    In case your Grub menu appears on every boot automatically the pressing the <Shift> key is not required.
  3. In the Grub menu go down from "Linux Mint" to "Linux Mint Advanced Options". Press enter.
  4. In the Advanced Options menu go down to "Linux Mint (recovery mode)". Press enter.
  5. In the next menu, which will appear after a while, go down to root-shell. Press enter.
  6. You will have to press enter one more time to confirm you want the root-shell.
  7. You will see the root-shell prompt # . You are now user root.
  8. Invoke the editor nano and load the file /etc/hostname. Command: nano /etc/hostname
    Change the word charlie-ThinkPa to read charlie-ThinkPad.
    Press <Ctrl>X.
    Confirm to save the changed file by pressing y.
    nano will save the file and terminate.
  9. Invoke the editor nano and load the file /etc/hosts. Command: nano /etc/hosts
    Change the line 127.0.1.1 charlie-ThinkPad-SL500.home to read 127.0.1.1 charlie-ThinkPad.
    Press <Ctrl>X.
    Confirm to save the changed file by pressing y.
    nano will save the file and terminate.
  10. Reboot the machine by typing reboot and pressing enter.
  11. Permit Linux Mint to startup normally.
  12. Once you have logged in to the graphical desktop, open a terminal window.
    Try a harmless sudo command in order to check whether the problem has been resolved.
    E.g. sudo who am i
HTH,
Karl
Image
Linux Mint 18.1 64-bit Cinnamon Desktop, Total Commander 9.22a 64-bit
Ubuntu 18.04.2 32-bit Mate Desktop, Total Commander 9.22a 32-bit
Windows? - 1 window in every room

User avatar
AndyMH
Level 7
Level 7
Posts: 1999
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: sudo: unable to resolve host charlie-ThinkPa

Post by AndyMH » Sat Jun 15, 2019 6:10 pm

My very first post on this forum was similar but different, there was and maybe still is a limit of 15 characters on a netbios name, which charlie-ThinkPad-SL500.home exceeds. Count the characters in charlie-ThinkPa :D Don't know what truncated it. Have you been playing around with samba and networking?

Since then I've kept my hostnames short, e.g. T430, D8400
Last edited by AndyMH on Sat Jun 15, 2019 6:13 pm, edited 1 time in total.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, Thinkpad T430 i7-3632 Cinnamon 19.0, Thinkpad T420 Cinnamon 18.3, Thinkpad T410 Cinnamon 17.3, Thinkpad T60 19.0 Mate

User avatar
karlchen
Level 20
Level 20
Posts: 10714
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: sudo: unable to resolve host charlie-ThinkPa

Post by karlchen » Sat Jun 15, 2019 6:12 pm

Hi, WharfRat.

How did you know that
a) we are on Mint 18.x, not 19.x?
b) that gksudo would work where sudo fails?

Cheers,
Karl
Image
Linux Mint 18.1 64-bit Cinnamon Desktop, Total Commander 9.22a 64-bit
Ubuntu 18.04.2 32-bit Mate Desktop, Total Commander 9.22a 32-bit
Windows? - 1 window in every room

User avatar
WharfRat
Level 21
Level 21
Posts: 12897
Joined: Thu Apr 07, 2011 8:15 pm

Re: sudo: unable to resolve host charlie-ThinkPa

Post by WharfRat » Sat Jun 15, 2019 6:55 pm

I'm on Sylvia (18.3) at this time so for a)

Code: Select all

[bill@XPS] ~/Downloads $ xed admin:///etc/hostname

** (xed:28605): WARNING **: The specified location is not supported
[bill@XPS] ~/Downloads $ 
For b)

I saw it somewhere, but I don't remember where :?
ImageImage

User avatar
ricardogroetaers
Level 3
Level 3
Posts: 130
Joined: Sat Oct 27, 2018 3:06 am
Location: Rio de Janeiro, Brasil

Re: sudo: unable to resolve host charlie-ThinkPa

Post by ricardogroetaers » Sat Jun 15, 2019 11:49 pm

cmtuck wrote:
Thu Jun 13, 2019 3:35 pm
I am unable to enter my password in the terminal window. ...
cmtuck,
Password works in graphical interface?
Try launching applications that require password. For example:
- Synaptic
- Software sources (Program sources)

If these applications can be released, you can edit the referenced files by opening the "/ etc" folder as root in the File Manager and opening the files with the text editor.

I would prefer to edit the settings by the "network" program (Configure network devices and connections).
Do not confuse with "Network Connections" (Manage and change your network connection settings).

In the picture, the correct program is the one on the left.

Image
https://i.imgur.com/HPGduy6.png

In the picture below, two instances of the program were opened simultaneously for better clarity.

Image
https://i.imgur.com/Rp7X5kP.png
General -> machine name = Machine -> ip address / Nickname

Note: Mr. Moderator, I could not put the pictures in the post, nor with "witchcraft".
Last edited by karlchen on Sun Jun 16, 2019 6:13 am, edited 1 time in total.
Reason: screenshot previews added, not by witchcraft, but by enclosing links to images in [rimg] [/rimg] tags

cmtuck
Level 1
Level 1
Posts: 6
Joined: Thu Jun 13, 2019 3:17 pm
Location: Vancouver, BC Canada

[SOLVED] sudo: unable to resolve host charlie-ThinkPa

Post by cmtuck » Sun Jun 16, 2019 2:25 am

Thanks everyone for your help. I finally used Karl's suggestion to perform a recovery, and it worked first time!

Charlie

Post Reply

Return to “Newbie Questions”