sudo: unable to resolve host

CptCharis

Well-Known Member
Joined
Feb 27, 2018
Messages
562
Reaction score
465
Credits
970
Hello everybody!!!

I changed my hostname in /etc/hostname
but I can't use sudo anymore

Code:
sudo: unable to resolve host

Any suggestion ?
 
Last edited:


OP
CptCharis

CptCharis

Well-Known Member
Joined
Feb 27, 2018
Messages
562
Reaction score
465
Credits
970
I changed it also /etc/hosts but things were worst.
Finally I place back my old hostname in both files and problem solved but this is not a solution.
I will google and I will be back with updates.
 
Last edited:

wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
7,512
Reaction score
6,355
Credits
26,574
I was going to say you need to do it in both, but you got that, goodonyer.

So now I am curious.

I'll await your searches.

Cheers

Wiz
 
OP
CptCharis

CptCharis

Well-Known Member
Joined
Feb 27, 2018
Messages
562
Reaction score
465
Credits
970
Hey @wizardfromoz

Problem solved ;)

I found this command

Code:
sudo hostnamectl set-hostname new-name

My hostname was changed succefully & no any error appears when I use SUDO

FYI hostname was changed in "hostname" file but not in "hosts" file and all this is strange bcz is what exactly I did manually.
I don't really now but with this command no more errors.

C u around!!!

P.S I forgot to mention that now when SUDO is used , is asking for passwd of old Hostname
propably bcz is not changed in hostname file.

:)
 
Last edited:

wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
7,512
Reaction score
6,355
Credits
26,574
Goodonyer again :D

Other than that, you could have appended (added) a new hostname in the file after the old, and it sees it as an alias for the other.

On password

Code:
sudo passwd

Cheers

Wiz
 
OP
CptCharis

CptCharis

Well-Known Member
Joined
Feb 27, 2018
Messages
562
Reaction score
465
Credits
970
Hello guys!!!
By the way , I find a much more easier way to change your Host name without any problems.

Menu>Administration>Network
under Network Settings window, in the first tab named General

press unlock & change your Host name.
Don't forget to lock again.
Host name is changing both hosts and hostname files in /etc.
That's it. Thanks.
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online


Top