Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

Sudo Unable to Resolve Host Name or Service Not Known

July 8, 2024
in A, Blog, Linux
0
ADVERTISEMENT

Table of Contents

Sudo unable to resolve host name

As you know, while installing a new operating system like Debian, Ubuntu, or any other Linux distribution, installers ask you to set the hostname. At that time, most users keep the default hostname.

But later, you have decided to change the hostname to some meaningful text, therefore you have modified the /etc/hostname to update the hostname.

And after the restart, you invoke the sudo command, which gives the error message sudo: unable to resolve host your-hostname: Name or service not known.

OPSHyP3xzFomyjTStsUOZ3jBw4pVUU9bexLGBhu7P7DreFXz37Eicb0drtxU

You will encounter the above error after making changes to /etc/hostname. And the resolution of this error is pretty simple.

1. First, SSH to the server then find your current machine hostname. In my case, it is cyberpanel, and to verify that, paste the below code on your terminal to find out:

cat /etc/hostname
root@cyberpanel:/home/bonben# cat /etc/hostname
cyberpanel

2. 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.

cat /etc/hosts
root@cyberpanel:/home/bonben# cat /etc/hosts
127.0.0.1 localhost vps01

# 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
ff02::3 ip6-allhosts

Now I found my problem. My hostname is an older one vps01, and the latest hostname or machine-name is cyberpanel.

3. So, simply modify the /etc/hosts with the correct hostname. Make sure to replace the machine with the actual hostname name. You can use any command line editor to modify /etc/hosts. In the following example, I’m using Nano to edit the file.

sudo nano /etc/hosts
root@cyberpanel:/home/bonben# cat /etc/hosts
127.0.0.1 localhost cyberpanel

# 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
ff02::3 ip6-allhosts

Once the file is modified save and close it. After that, try to execute the sudo command again and you will see that the error no longer bothers you.

adWK5gVsmTjymaKOqb6r7E8AfU4ZnXEAwz8PHtatubx1r8kFmTWYCMVq6nGo
ADVERTISEMENT

Not a reader? Watch this related video tutorial:

5/5 - (1 vote)
Previous Post

How to Restore the Port 8090 in CyberPanel

Next Post

How to Install CyberPanel on Centos 7 Linux

Related Posts

Images Hidden Due To Mature Content Settings In CivitAI

August 31, 2024

Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

August 20, 2024

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024

How to Remove The Test Mode Watermark Without Disabling Test Mode

July 28, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory