I have changed my hostname in linux mint and after that my sudo works slow I mean how to change the etc/sudoers back again to work properly or there is anything else that I have to change
4 Answers
you probably need to edit /etc/hosts
to reflect your new hostname
otherwise it tries to find info about it via DNS (and timeouts, most probably)
look for:
127.0.0.1 localhost oldname
and change to:
127.0.0.1 localhost newname
Of course change only the line corresponding to oldname. Above I gave an an example of a machine which isn't connected to the net...
Below I give an example of a machine which have an IP:
127.0.0.1 localhost
a.b.c.d oldname <-- just edit that line
-
@saurabh: did it help? (you should also look into /etc/resolv.conf to find out if you are using the host files or another mechanism...) (and I could also be wrong on the reason of the slowness after a changed hostname, but it seems you are in this case) Mar 7, 2014 at 12:22
-
Can you explain why did it happen I mean why do the sudo cmd got slow– saurabhMar 7, 2014 at 12:28
-
it made probably more than sudo slow: any time a command was looking for your hostname, it tried first /etc/hosts, and then asked the DNS... Mar 7, 2014 at 12:36
Problem solved. I describe to help others.
I've had the same problem. All configurations were correct, but login via ssh and sudo were extremely slow.
cat /etc/hostname was correct, but something did not work.
I solved by changing the hostname NOT from the file but by the command
hostname name-of-the-host
In this way the problem has disappeared. Probably using the hostname command are done other operations and the modification is more complete than just modifying the /etc/hostname file manually.
Slowliness can be caused by not being able to resolve hostnames. This might be because of wrong entries in /etc/hosts or because of wrong settings in /etc/resolv.conf
Verify both so they be correctly configured. After that continue to the sudoers file.
Have you used the old hostname in the sudoers file, then update the sudoers content to reflect the changes.
find out what your current hostname is:
hostname -f
Edit the /etc/hosts
file:
sudo vim /etc/hosts
change
127.0.0.1 oldhostname
to
127.0.0.1 current_hostname