tips

How To Fix Sudo Unable To Resolve Host Error Easily

Some operators run into the error “sudo unable to resolve host” message. Typically, this error occurs when you change the computer name. This is a simple problem that can be solved in a simple way.

Normally, When the terminal system gets stuck on “”sudo: unable to resolve host (none)” or “sudo: the host cannot be recognized”; it means that you did not enter the hostname of your system.

The hostname is the name of the device with which it identifies the network. Also, the IP address is stored locally in “/etc/hostname” directory and mapped to the network for communication.

In this post, we’ll look at why this error occurs, what it means, and how to fix this problem with Ubuntu, Fedora and/or other Linux operating systems.

Steps to Fix Sudo Unable To Resolve Host

The message “Sudo unable to resolve host host” means that the utility cannot determine the IP address of the “hostname“. It would seem that sudo is a local command to increase permissions on the system and does not have to define IP hosts. But this is not the case, sudo can be used by remote users, for example, connected via SSH.

And now we are interested in what for every query the tool must determine which host is used on this computer. In short, the main idea of programmers is that one universal / etc / sudoers file will be used on many computers and each computer must specify what rules are intended for it. Therefore, the host variable in sudoers only affects local rules.

And now we are coming back to our error. As I said, this means that the tool cannot resolve the hostname. In the case of a website domain, this would mean that there is no such record in DNS. But because it is the name of our local computer, it is obvious that it is not in the global network.

How to fix the error.

The solution is located in / ETC / HOSTS

To fix this error, you can add this DNS record close by to the / etc / hosts file. Because sudo does not work for you, and this file can be edited only by the administrator, this simple task becomes more complicated. First, we look at our current hostname:

hostname

Then, if you have a root password, you can log in to it using su:

su –

Then make sure to add this line to / etc / hosts:

vi / etc / hosts

127.0.0.1 hostname

You should replace the hostname with the “hostname” you received using the hostname command. Then you need to restart the computer or simply restart the network:

sudo systemctl restart the network

It is also advisable to make sure that the / hosts file usage is enabled in the Domain Name System Service. Open the file /etc/nsswitch.conf and search for files on the host line. This should be in the first place. If not, move it to the first place.

If you do not have the root password, you need to boot from the LiveCD drive, mount the root filesystem in / mnt / and fix the error there.

Source and More Reading: https://www.psychz.net/client/question/en/sudo-unable-to-resolve-host.html

Search recipes for this entry:

  • sudo: unable to resolve host
Oscar Waterworth

Share
Published by
Oscar Waterworth