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.
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.
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.
Next, type:
sudo nano /etc/hosts
and add:
127.0.0.1 yourhostname
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@laptop
to tobias@newlaptop
you might need to update your /etc/hosts
:
127.0.1.1 laptop
needs to be changed to
127.0.1.1 newlaptop
If you get it right sudo
should work without delay immediately after saving this setting.
Answer 1
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
and add 127.0.0.1 yourHostName
to it
also in some distros 127.0.1.1 yourHostName
should be replaced
Answer 2
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
/var/log/auth.log
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...
hostnamectl
, I get "Failed to query system properties: Connection timed out". The hostname returned by hostname
already has a 127.0.0.1 entry in /etc/hosts, but the problem persists.
– appas
Sep 16 '20 at 04:21
authconfig --disablefingerprint --update
– gdm
Nov 20 '21 at 08:02
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)