If rpm / yum command hangs during operations or you see error messages – it means your rpm database corrupted. /var/lib/rpm/ stores rpm database just delete the same and rebuild rpm database:

Command to rebuild rpm database

rm -f /var/lib/rpm/__db*
rpm --rebuilddb

Read rpm / yum man pages for more information

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 7 comments so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
7 comments… add one
  • Jerto Apr 27, 2009 @ 17:55

    Thanks for the help.

  • Avin Mar 3, 2010 @ 12:13

    Thanks………..This is simple and Best solution..

  • Robert Peckham Jun 30, 2010 @ 16:01

    Thanks again, NixCraft!

  • Rajnish Kumar Jul 7, 2011 @ 7:40

    Hi i am facing the same problem , i an not able to install any rpm through rpm commands or yum .
    when i run rpm -ivh package name i got below error :
    error: can’t create transaction lock on /var/lib/rpm/__db.000
    even i am not able to remove the /var/lib/rpm then __db.00* file
    i got the below error :=
    [root@Rajnish rpm]# rm -rf __db.00*
    rm: cannot remove `__db.001′: Permission denied
    rm: cannot remove `__db.002′: Permission denied
    rm: cannot remove `__db.003′: Permission denied
    [root@Rajnish rpm]#

    i am using centos 5.4 for Detaill :-
    uname -a
    Linux Rajnish 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:14 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

    any suggestion . how can i get out from here .

  • Alden Jul 24, 2011 @ 1:24

    I have had this problem in the past. I *believe* it happens when a running process is accessing the files.

    Also, are you running as root? That could be why you are getting the “Permission denied” error.

  • Ankit Jun 6, 2012 @ 6:35

    Thnks alot 🙂 it was sucks too mch thanks once again 🙂

  • Tim Sep 19, 2012 @ 18:20


    I hit this same problem. Your solution put me in the right direction, however, your syntax needs a little more. Please try the following instead.

    cd /var/lib/rpm
    rm -rf __db*
    rpm –rebuilddb

    Note the ‘r’ for recursion in the remove command.


Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum