Use yumdb command with DNF to list explicitly installed packages

Since Fedora 22, DNF has replaced Yum as the default package manager. But not all yum commands have been migrated.

Today I felt like querying what packages I installed explicitly, and a quick Google told me to use yumdb search reason user, but it returned nothing.

I dug into the cause, and it turns out DNF now has its own yumdb (the database, not the command, sadly) at “/var/lib/dnf/yumdb”, along with yum’s “/var/lib/yum/yumdb”, and the command yumdb uses the latter by default.

In the man page of yum.conf, it says the “persistdir” value controls the path of yum’s db files, and it defaults to “/var/lib/yum”; but, yumdb --help tells me that it allows me to specify the location of config file. (Cheering for not touching /etc/yum.conf)

So, here’s what I did:

  1. Create a new fake config file with persistdir set to DNF’s folder.
    echo '[main]\npersistdir=/var/lib/dnf' > /tmp/dnf.conf
  2. Calls yumdb with that config file.
    yumdb -c /tmp/dnf.conf search reason user

Voila.

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注