pop-os / pop

A project for managing all Pop!_OS sources
https://system76.com/pop
2.46k stars 87 forks source link

Slow sudo fixed #3367

Open esotericpig opened 2 months ago

esotericpig commented 2 months ago

Distribution (run cat /etc/os-release):

NAME="Pop!_OS" VERSION="22.04 LTS" ID=pop ID_LIKE="ubuntu debian" PRETTY_NAME="Pop!_OS 22.04 LTS" VERSION_ID="22.04" HOME_URL="https://pop.system76.com" SUPPORT_URL="https://support.system76.com" BUG_REPORT_URL="https://github.com/pop-os/pop/issues" PRIVACY_POLICY_URL="https://system76.com/privacy" VERSION_CODENAME=jammy UBUNTU_CODENAME=jammy LOGO=distributor-logo-pop-os

Related Application and/or Package Version (run apt policy $PACKAGE NAME):

Issue/Bug Description:

Sorry, not sure if this has been posted before or resolved yet

I just got a completely new System76 laptop recently. I've updated everything and restarted multiple times.

Anyway, I was noticing that any sudo command was running very slowly, like 3-5 seconds to run this:

sudo echo 'hi'

I had changed my hostname by going to Settings (gui) => About. This is how I've always done it on Fedora, etc.

Anyway, after searching online, I found the solution was by updating /etc/hosts:

Original:

127.0.0.1   localhost
::1     localhost

Updated with "example" as hostname:

127.0.0.1   localhost   example example.localdomain
::1     localhost   example example.localdomain

Now sudo echo 'hi' runs in a few milliseconds.

It probably requires an upstream fix, but it seems pretty important to me.

mmstick commented 2 months ago

I have a custom hostname, and also have this in my hosts file

# See `man hosts` for details.
#
# By default, systemd-resolved or libnss-myhostname will resolve
# localhost and the system hostname if they're not specified here.
127.0.0.1   localhost
::1     localhost

It's not necessary to add the hostname to the file because systemd-resolved will automatically resolve it if it is not defined. The 3-5 second delay is what you get when a hostname was defined that doesn't match the actual hostname on the system. So this can be avoided by not specifying it in the hosts file.

esotericpig commented 2 months ago

Oh, that's odd. For me, for some reason, if I just have this, it's 3-5 seconds slow for me:

127.0.0.1   localhost
::1     localhost
alex-free commented 1 month ago

I hope every distro does this, I have a script called fsudo which I run on every install of Linux.