Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow sudo fixed #3367

Open
esotericpig opened this issue Aug 30, 2024 · 3 comments
Open

Slow sudo fixed #3367

esotericpig opened this issue Aug 30, 2024 · 3 comments

Comments

@esotericpig
Copy link

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
Copy link
Member

mmstick commented Aug 30, 2024

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
Copy link
Author

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants