Issue when sudo something after a hostname change
5,050
Solution 1
Have you defined your new hostname in your /etc/hosts
file?
When changing your hostname, you need to alter it in both the /etc/hostname
and /etc/hosts
files. And once you've done that, either reboot or restart the hostname service:
sudo service hostname restart
Solution 2
Change this line in /etc/hosts
:
127.0.1.1 your-old-hostname
to:
127.0.1.1 your-new-hostname
Related videos on Youtube
Author by
ovrwngtvity
Updated on September 18, 2022Comments
-
ovrwngtvity over 1 year
I was tired of my system's name so i decided to change it. I
gksudo gedit /etc/hostname
and changed my first and never touched computer name to a new one. Then now when isudo
something likesudo gedit
my terminal prompts~: unable to resolve host <my_new host_name_i_gksudo>
.When i
sudo cat /etc/hosts
it gives me:sudo: unable to resolve host <not_of_your_business!> 127.0.0.1 localhost 127.0.1.1 leviathan # 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
How could i get rid of this problem? Thanks in advance.
-
user.dz over 10 yearsUse
su -
but if you didn't setup root password, boot to recovery mode.
-