I noticed that the terminal recently becomes too slow when I execute a command that needs my password. It takes some seconds to display [sudo] password for ...
I'm using Dell XPS developer edition (i7,8G RAM) with Ubuntu 13.04 64bit.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
Hi I found this answer on another question - The problem is if your hostname is not in your hosts file.
basically, type "hostname" in your terminal. That will tell you what your hostname is.
sudo nano /etc/hosts
then save - and you are done! Sudo should be fast now!
When you change your systems name in Gnome (The part that is displayed in the terminal after the @; e.g.
tobias@newlaptop you might need to update your
needs to be changed to
If you get it right
sudo should work without delay immediately after saving this setting.
Confirmed @Paul Preibisch answer for those who want more detailed answer
I had this issue for a long time and all I did was to run
hostnamectl | grep -i "static hostname"
this will show you your hostname then copy the value and edit your hosts
sudo vim /etc/hosts
127.0.0.1 yourHostName to it
also in some distros
127.0.1.1 yourHostName should be replaced
Please note that in many cases the
answer 1 will solve your problem if it didn't you have to check your
sudo log which in debian based distros is under
so you can watch your sudo log with tail command
sudo tail -f -n 100 /var/log/auth.log
then open another terminal and run a sudo command like:
sudo ls /
go back to your first terminal and read the log, in my case the problem was due to
pam_krb5 authentication failure the log was:
sudo: pam_krb5(sudo:auth): authentication failure;
after I removed it sudo command worked instantly...
Thanks to @gdm for giving the clue...
For the lazy - Just copy paste this in your terminal :)
echo -e '127.0.0.1\t' $(hostnamectl | grep -i "static hostname:" | cut -f2- -d:) | sudo tee -a /etc/hosts
sudo should be fast after you run this
Edit - Explaining this command in more detail:
It first grabs your localhost cutting the label string ahead (hostnamectl | grep -i "static hostname:" | cut -f2- -d:) e.g. mylocalhost
It concatenates it with 127.0.0.1 ahead ("\t" means tab character)
It take the full string created above (127.0.0.1 mylocalhost) and adds it to the end of /etc/hosts (you need sudo to edit the hosts file)