Or help me out by engaging with any advertisers that you find interesting
I recently suffered an unusual issue in the Linux terminal. Any commands prefixed with sudo would take 10 to sometimes 15 seconds to execute, while all other bash and terminal commands would operate at speed.
Initially, I thought the issue was related to a Ubuntu Server install running in VMware Fusion on a low powered Mac laptop, but it didn’t make sense that only the superuser-do initiated commands would suffer from this speed effect. But after much Googling, I discovered, surprisingly the issue was related to an incorrect network setting, and that the long pause was a network timeout! I imagine my VMware configuration of Internet Sharing – Share with my Mac (NAT) was the cause of the issue, but thankfully there was a speedy fix.
Firstly if your suffering from this issue,
sudo -V should take too long to complete.
Create a backup of the hosts configuration file, and sadly, this too will take a long time.
sudo cp /etc/hosts /etc/hosts.original
Determine the hostname of the system.
$ hostname devtidbits.lan
Take note of the result, and it’s usually a single item such as devtidbits.lan. If no output returns then this nixCraft guide may help.
Edit the hosts configuration file and modify the localhost entries on the first two lines. The first line is for IPv4. The second is for IPv6 and at the end of each line append the hostname result.
sudo nano /etc/hosts
For example, before:
127.0.1.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6
127.0.1.1 localhost.localdomain localhost devtidbits.lan ::1 localhost6.localdomain6 localhost6 devtidbits.lan
Problem fixed, now running
sudo -V or any other sudo prefixed command should be instantaneous!
Written by Ben Garrett