Recently I've been having the issue that some rpm commands (e.g. # rpm --rebuilddb fail due to this error:

error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Permission denied)

It also seems this affects PackageKit as whenever I try to open GNOME Software's updates tab it says "Timeout was reached".

To me, it seems like some rpm transaction was aborted while running and now the lock file is stuck there. I would just remove the file, but I'm not sure how to tell whether it's safe.

[neboula@shock ~]$ file /var/lib/rpm/.rpm.lock
/var/lib/rpm/.rpm.lock: empty
[neboula@shock ~]$ pidof dnf
[neboula@shock ~]$ pidof rpm

This looks like it's safe, but I also have packagekitd (always) running, so I'm wondering: How can I safely remove this file given my circumstances?


Check if any rpm processes exists

ps -axwww | grep rpm

kill them

kill -9 <pid>

Remove the lock files

rm -rf /var/lib/rpm/__db*

Rebuild RPM database

rpm --rebuilddb
  • 1
    I'm not sure telling people to unconditionally kill rpm processes is a good idea? Also, what about PackageKit? Would PackageKit transactions be caught by this method?
    – Newbyte
    Apr 27 '21 at 7:43
  • rm -rf /var/lib/rpm/__db* - I really don't like this command. --rebuilddb normally takes care of these files and I'm not sure these files are safe to delete. Apr 27 '21 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.