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 i sudo something like sudo 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!>   localhost   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.

  • Use su - but if you didn't setup root password, boot to recovery mode. – user.dz Feb 7 '14 at 20:14

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
| improve this answer | |

Change this line in /etc/hosts:     your-old-hostname

to:     your-new-hostname
| improve this answer | |

The sudo command can take a hostname parameter. eg.

sudo -h my-new-hostname reboot

P.S. After the reboot, it should all be happy assuming you've changed your hostname correctly.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.