sudo is sometimes slow if the hostname has been changed from `pureos` (/etc/nsswitch.conf)
##TL;DR
- if the hostname has been changed to something other than the default
pureos
it can sometimes take a long time for thesudo
password prompt to show up - put
myhostname
beforedns
in/etc/nsswitch.conf
in thehosts:
line
Spawned from a recent discussion on matrix starting at https://matrix.to/#/!FwbcAdwtvCYkHekZKf:talk.puri.sm/$0lyWbU8NOF2eIUAQ1dnvYsJwAOdujg43MyqgpDOfAns?via=talk.puri.sm&via=matrix.org&via=librem.one
I mitigated this locally by adding my hostname in /etc/hosts
, but @sebastian.krzyszkowiak pointed the manpages which read
It is recommended to place "myhostname" after "file" and before "dns". This resolves well-known hostnames like "localhost" and the machine hostnames locally. It is consistent with the behaviour of nss-resolve, and still allows overriding via /etc/hosts.
while I had myhostname
after dns
, not before.
I've switched the order and will observe if I ever have slow sudo again.