![]() For more information on these topics, you can refer to the Ubuntu documentation here. In such cases, you may need to explore other solutions, such as modifying the DNS settings or using aliases for sudo. If you’re still experiencing issues, it might be due to illegal characters in the hostname or issues with the DNS configuration. Remember to always exercise caution when modifying system files, and always back up any important files before making changes. You can do this by running the following command: sudo reboot Conclusionīy following these steps, you should be able to resolve the “sudo: unable to resolve host (none)” error in Ubuntu. Rebooting Your MachineĪfter making these changes, reboot your machine to apply them. If it doesn’t, add or modify the entry accordingly. You should see an entry that looks something like this: 127.0.1.1 your-hostnameĮnsure that your-hostname matches the hostname you’ve been using. You can open it in a similar manner to the previous file: sudo nano /etc/hosts This file should contain an entry for your hostname. Next, we’ll need to check the /etc/hosts file. In nano, you can do this by pressing Ctrl + X, then Y to confirm the save, and finally Enter to exit. Once you’re done, save the changes and exit. The sudo command gives you root privileges, nano is a text editor, and /etc/hostname is the file you want to edit.Įnsure that the hostname in this file matches the hostname you retrieved earlier. We’ll use nano in this example: sudo nano /etc/hostname ![]() You can open this file using a text editor with root privileges. The next step is to ensure that the hostname in the /etc/hostname file matches the hostname you just checked. This command will return the current hostname of your machine. You can do this by running the following command in the terminal: hostname Checking the Hostnameįirst, let’s check the hostname of your machine. If there’s a discrepancy, it throws the error message. When you run a sudo command, the system checks these two files to verify the hostname. The “sudo: unable to resolve host (none)” error is usually due to a mismatch between the hostname defined in the /etc/hostname file and the hostname entry in the /etc/hosts file. ![]() That’s all for this guide to fixing the error.Įven after following these steps, if you still face the issue, then do let me know in the comment section.Īs a side note, you can also use the hostenamctl command to change the hostname of your system without manually making any changes to /etc/hostname.Before we dive into the solution, it’s important to understand why this error occurs. Once you’re done with the changes, you can execute the command that raised the above error. Like here, I have replaced the old hostname with the new hostname, and now let me save and close the file. If you are not finding the hostname in the following, simply paste the highlighted line into the file by replacing it with your hostname and save the file. So, simply modify the /etc/hosts with the correct hostname. Very few people know How to use cat and tac command in Linux $ cat /etc/hostname # Host addressesĪs you can see, my system hostname is trendoceans-HUB1, but here “SHEN” is still appearing, which makes a system print error about the hostname being incorrect. The output shows the main culprits lie here. Once you know the machine-name or hostname from /etc/hostname, you can proceed to /etc/hosts to find the existence of your machine name in the respective file. Like in my case, it is “trendoceans-HUB1”. Once in a while, you will encounter the above error after making changes to /etc/hostname, and fixing this issue is no more complicated than a few simple steps.įirst and foremost, find your current machine’s hostname, which you can do by running the following command: $ cat /etc/hostname Fix: Sudo Unable to Resolve Host Name or Service Not Known Error So, let’s learn how to fix the sudo unable to resolve host name or service not known in your Linux system. However, after restarting your system, when you invoke the sudo command, you encounter an error message that states “sudo: unable to resolve host your-hostname: name or service not known.” Getting error sudo unable to resolve host name or service not known after executing the sudo command, then read these steps to fix it up.Īs you know, while installing a new operating system like Debian, Ubuntu, or any other Linux distribution, installers ask you to set the hostname.Īt that time, most users kept the default hostname.īut later, you decided to change the hostname to some meaningful text, which can help you identify your system easily, and to do that, you may have followed this article or directly mentioned the new hostname in the /etc/hostname file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |