When I use the dnf command, it starts to update repositories and it takes a while, especially when the OS is outdated. Sometimes I need to use dnf info or something like that and I don't need it to be updated. How can I use it in a way it does not search for update?
2 Answers
Use the --cacheonly (or -C) option; this will use the system cache only, without updating it.
Using --setopt=metadata_expire=never never mark metadata as expired, you may get old version of package or download failed (old package may be deleted in repo server).
dnf install --setopt=metadata_expire=never <package> Using --cacheonly aka -C only use cache, if you never dnf install or dnf download the package before to cache it, this will fail. And this swicth never updates metadata for sure.
dnf install -C <package>
rpmcommands that are local-only, e.g.rpm -qi packagenameto get the info on an installed package.