Slow to Sudo on Ubuntu 18.04

I am on a Ubuntu 18.04 system that is very slow when issuing any command via sudo. It can take 30 seconds for the command to complete. Any other command is completed instantaneously.

The system has very little CPU and memory usage with no resource issues over a very long period of time. If I do sudo su and switch to root, I am able to run commands simultenously. It is only an issue when running sudo

It’s weird, but does your hosts file match your hostname? People have reported that to make it slow.

Eh, never mind I see you mentioned that on the other site.

One of the tests I found is:

logger 'Hello world'
  1. Does the command return within a reasonable amount of time?
  2. Does ‘Hello world’ show up in /var/log/syslog ?

If this is not the case, the syslog daemon has crashed. Restarting it should fix your problem.

service rsyslog restart

So it ended up being my hosts file. I only had localhost in there, but needed systemname as well localhost systemname