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

  • 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

  • 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