Skip to content

RPM CHEATSHEET

Common usage of yum/dnf to do nifty things.

FEDORA DUMP/IMPORT RPMS TO/FROM FILE

  • Dump

    dnf repoquery -a --installed --qf "%{name}" > rpms.txt
    
  • Import

    dnf -y install $(cat rpms.txt)
    
    or
    
    cat rpms.txt | xargs dnf -y install
    

EL6, EL7, AMAZON LINUX DUMP/IMPORT RPMS TO/FROM FILE

  • Dump

    repoquery -a --installed --qf "%{name}" > rpms.txt
    
  • Import

    yum -y install $(cat rpms.txt)
    
    or
    
    cat rpms.txt | xargs yum -y install
    

SEARCH FOR INSTALLED PACKAGES FROM SINGLE REPOSITORY

  • EL8+, Fedora

    dnf search from_repo REPONAME |awk -F"\n" '{ RS=""; print $1 }'
    
  • EL6, EL7, Amazon Linux

    yumdb search from_repo REPONAME | awk -F"\n" '{ RS=""; print $1 }'
    

REMOVING ALL PACKAGES FROM A SINGLE REPOSITORY

  • EL8+, Fedora

    dnf repository-packages REPOID remove
    
  • EL6, EL7, Amazon

    yum repository-packages REPOID remove
    

RPM DEPENDENCY ERRORS

PACKAGE WENT AWOL

Not sure why this can occur, but it does. When an update or package install happens, you should pull in any new dependencies that arrive. Should this fail, here is how to fix it.

    sudo yum check
    sudo yum reinstall BROKEN_PACKAGE
    sudo yum check

Here is a sample output, forced by removing fuse-sshfs

  • The error noticed while doing another transaction

    Warning: RPMDB altered outside of yum.
    ** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
    x2goserver-4.0.1.20-1.el7.x86_64 has missing requires of sshfs
    
  • Troubleshoot

    $ sudo yum check
    Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos,
                  : subscription-manager
    x2goserver-4.0.1.20-1.el7.x86_64 has missing requires of sshfs
    Error: check all
    
  • Fix

    $ sudo yum reinstall x2goserver
    Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos,
                  : subscription-manager
    Resolving Dependencies
    --> Running transaction check
    ---> Package x2goserver.x86_64 0:4.0.1.20-1.el7 will be reinstalled
    --> Processing Dependency: sshfs for package: x2goserver-4.0.1.20-1.el7.x86_64
    --> Running transaction check
    ---> Package fuse-sshfs.x86_64 0:2.5-1.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ================================================================================
     Package            Arch           Version                   Repository    Size
    ================================================================================
    Reinstalling:
     x2goserver         x86_64         4.0.1.20-1.el7            epel         108 k
    Installing for dependencies:
     fuse-sshfs         x86_64         2.5-1.el7                 epel          58 k
    
    Transaction Summary
    ================================================================================
    Install               ( 1 Dependent package)
    Reinstall  1 Package
    
    Total download size: 166 k
    Installed size: 440 k
    Is this ok [y/d/N]: y
    Downloading packages:
    (1/2): fuse-sshfs-2.5-1.el7.x86_64.rpm                     |  58 kB   00:05     
    (2/2): x2goserver-4.0.1.20-1.el7.x86_64.rpm                | 108 kB   00:00     
    --------------------------------------------------------------------------------
    Total                                               27 kB/s | 166 kB  00:06     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : fuse-sshfs-2.5-1.el7.x86_64                                  1/2
      Installing : x2goserver-4.0.1.20-1.el7.x86_64                             2/2
      Verifying  : x2goserver-4.0.1.20-1.el7.x86_64                             1/2
      Verifying  : fuse-sshfs-2.5-1.el7.x86_64                                  2/2
    
    Installed:
      x2goserver.x86_64 0:4.0.1.20-1.el7
    
    Dependency Installed:
      fuse-sshfs.x86_64 0:2.5-1.el7
    
    Complete!
    
  • Ensure nothing else is broken

    $ sudo yum check
    Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos,
                  : subscription-manager
    check all
    

DUPE PACKAGES

If you run into an issue where you have one or more of this:

Error:  Multilib version problems found. This often means that the root
       cause is something else and multilib version checking is just
       pointing out that there is a problem. Eg.:

         1. You have an upgrade for libcurl which is missing some
            dependency that another package requires. Yum is trying to
            solve this by installing an older version of libcurl of the
            different architecture. If you exclude the bad architecture
            yum will tell you what the root cause is (which package
            requires what). You can try redoing the upgrade with
            --exclude libcurl.otherarch ... this should give you an error
            message showing the root cause of the problem.

         2. You have multiple architectures of libcurl installed, but
            yum can only see an upgrade for one of those architectures.
            If you don't want/need both architectures anymore then you
            can remove the one with the missing update and everything
            will work.

         3. You have duplicate versions of libcurl installed already.
            You can use "yum check" to get yum show these errors.

       ...you can also use --setopt=protected_multilib=false to remove
       this checking, however this is almost never the correct thing to
       do as something else is very likely to go wrong (often causing
       much more problems).

       Protected multilib versions: libcurl-7.29.0-59.el7_9.1.x86_64 != libcurl-7.29.0-57.el7_8.1.x86_64
Error: Protected multilib versions: nx-libs-3.5.99.25-2.el7.x86_64 != nx-libs-3.5.99.24-1.el7.x86_64

Not a good issue to have, but very fixable. The caveat is likely a bit on the manual side.

So first we want yum to do whatever it can automatically for us to clean up any dupes.

sudo package-cleanup --cleandupes

If that doesn't fully fix it (sometimes you get lucky and it actually will), you can try this variation of the command instead:

sudo package-cleanup --cleandupes --removenewestdupes

If that still isn't quite doing it, then its going to be manual from here on.

To fix the above example, we need to remove the RPM DB entry for the older package, and reinstall the new one to ensure everything went properly.

sudo rpm -e --justdb libcurl-7.29.0-57.el7_8.1
sudo yum reinstall libcurl
sudo rpm --rebuilddb

sudo rpm -e --justdb nx-libs-3.5.99.24-1.el7
sudo yum reinstall nx-libs
sudo rpm --rebuilddb

sudo yum check

You will need to do that for each broken element and conclude with the yum check to validate all is good. The output there will also remind you of anything that still needs repair.