Workaround for slow sudo in Ubuntu (reproduced)

This problem was encountered recently when installing Ubuntu Server 18.04 LTS. I did not find this problem with Ubuntu Server 16.04 LTS.

Symptom: sudo is very slow. It takes about 10 seconds after submitting the command to enter the sudo password or start running. The symptoms of the su command are the same.

Reason: Ubuntu Server is designed to be similar to a distributed operating system network structure, allowing members in / etc / sudoers not to be on this machine. Therefore, sudo will first look for the possible sudoer on the network and then local. And the time of about 10s is the longest time of the entire DNS process.

Solution: First enter the hostname to get the current Internet name of the machine (probably similar to the computer name under windows). Then use su or sudo to open / etc / hosts and add a line:

127.0.0.1 <TAB> hostname <TAB> hostname.localdomain

Close and save, sudo speed returns to normal

Guess you like

Origin www.cnblogs.com/minost/p/12702694.html