RPM: Commands and Management

Discussion in 'Installation' started by DevynCJohnson, Jan 12, 2014.

  1. DevynCJohnson

    DevynCJohnson Well-Known Member Staff Member Staff Writer

    Messages:
    1,336
    Likes Received:
    1,074
    Trophy Points:
    113
    RedHat-based systems use RPM files as software installation packages. RPM stands for "RPM Package Manager" (yes, a recursive acronym). RPM files contain binary/compiled software and SRPM (S = Source) files contain source code. RPM files have the *.rpm extension and SRPM files use *.srpm or *.src.rpm. DeltaRPM and PatchRPM files are special patches for software in an RPM file or for software on an RPM system. These two patches use the *.rpm file extension.

    NOTE: RPM systems are Linux systems that use the RPM installation package. This is another way of saying RedHat-based system.


    Various front-ends exist for RPM. In this topic, a front-end is a program that manages, installs, receives, etc. RPM files. RPM files are usually downloaded from some repository. An RPM repository is a collection of hundreds or more RPM files on a server.

    apt-rpm
    - This is a tool that allows RPM systems to use APT. This software may soon become abandonware.

    up2date - This is like YUM, but it only updates packages using the repositories. Yum is being used in place of up2date.

    urpmi - This is a piece of software that uses the rpm command, but adds abilities allowing repositories to be accessed and dependencies to be resolved. Mandriva Linux uses this software and Rpmdrake is the graphical front-end (in this instance, a GUI for a command-line tool).

    yum - This is a popular RPM front-end which will be discussed later in this article.

    Zypper - Zypper is used by Tizen, MeeGo, Sailfish OS, and other systems. YaST is a GUI that uses Zypper. https://en.opensuse.org/Portal:Zypper

    To install an *.rpm package that is on the user's local storage device or in a remote location, use the "rpm" command with Root privileges and provide the parameters and file path. The syntax and parameters are relatively easy to learn and use. The RPM command has more parameters than are mentioned in this article.

    Install:
    Code:
    rpm -i <PATH>
    <PATH> may be a local path or an URL.

    Upgrade: Use this command to upgrade an already installed package
    Code:
    rpm -U <PATH>
    YUM:

    Yum is the most popular package manager for RedHat-based systems, so it is important to know some of the commands. Yum performs other tasks and has other parameters, but these are the ones most Linux users should know.

    yum install <PACKAGE> #This will install the listed packages from the repositories

    TIP: If you do not like typing "yum install" and would like a smaller command, add an alias to "~/.bash_aliases". Add a line like below and re-login to your system.
    Code:
    alias yul="yum install"
    yum localinstall <PATH_TO_PACKAGE> #This command will install a local *.rpm file just like "rpm -i <FILENAME>"

    yum remove <PACKAGE> #This will remove/uninstall the listed packages. "erase" is the same as "remove".

    yum update <PACKAGE> #List the currently installed software packages you wish to be installed. The new packages will come from the repositories.

    yum update #Update all packages

    yum upgrade #This will update all packages and (if possible) take the system to the next distro version (like Fedora 19 -> Fedora 20).

    yum list installed #List installed software
    rpm -qa #Same as above command

    YUM vs RPM:

    YUM and RPM have many similarities. However, there are two main differences. YUM can use repositories and manage package dependencies while RPM cannot. The RPM command can install remote packages, but the full web-address must be given while with yum, users can type the software's name (like "firefox"). This difference can be seen when installing Firefox as seen below (only the commands are shown, not the output).

    Code:
    #yum will complete successfully and download and install dependencies
    yum install firefox
    
    #rpm will fail because no address is given
    rpm -i firefox
    
    #Here, the syntax is correct (a URL is used). However, rpm cannot find or install dependencies
    rpm -i <SOME_URL_TO_FIREFOX_RPM>
    
    As seen in the command examples, RPM is only meant to install *.rpm files when the dependencies are already satisfied or will be manually installed first. On the other hand, YUM can search the repositories and install Firefox as well as its dependencies. In generally, most users should use "yum" instead of "rpm".

    NOTE: Also notice that the two commands use slightly different syntax - "rpm -i <FILE>"|"yum install <PACKAGE>".


    Zypper:

    Zypper is a lot like Yum and the syntax is relatively the same. Zypper is used on OpenSUSE. Zypper performs other tasks and has other parameters, but these are the ones most Linux users should know.

    zypper install <PACKAGES>

    zypper update <PACKAGES>

    zypper remove <PACKAGES>

    zypper patch --bugzilla <BUG NUMBER> #This command applies a patch (if available) to fix an issue/bug specified by the Bugzilla number


    Zypper vs YUM:

    Zypper and YUM are nearly the same. The two main differences are in syntax/parameters (most of which I did not cover) and performance. Zypper is faster than YUM, but many users like YUM's syntax better than Zypper. Many readers here may be wondering why YUM is used in more distros than Zypper. The main reason is due to the fact Zypper newer than YUM and is still being developed. YUM has been used for many years and is a very stable and trusted software manager. This is also the reason (or at least one of the reasons) why YUM is preferred over many other package managers.


    Using PatchRPM and DeltaRPM Files:

    Sometimes users may use a patch on some piece of software to fix a bug or guard against security flaws. A PatchRPM file is like a regular RPM file, but it is used to apply a patch. Also, the file is smaller since it contains a patch rather than the full software. To apply a PatchRPM file, use your preferred package manager and treat the patch as an update - "rpm -U <PATH_TO_PATCHRPM>".

    Only apply a patch if the installed software is compatible with the patch. To test for compatibility, try these commands -

    Code:
    rpm -q firefox
    
    rpm -qp --basedon <FIREFOX-PATCH>.rpm
    
    The first command will print the version of the currently installed version of Firefox. The next command will display the versions of Firefox that accept the patch. If the last command's output contains the version number of the currently installed package, then the patch can be applied.

    HELPFUL COMMAND: The command "rpm -qPa" lists all of the currently applied patches on the system.

    DeltaRPM files are patches that are applied to RPM files. DeltaRPM can be applied to installed software. The one difference between PatchRPM and DeltaRPM files is the file's size (DeltaRPM is smaller). Also, applying a DeltaRPM patch will require more CPU resources than applying a PatchRPM. The true definition/difference of the two lie in the structure, but these are some superficial signs that distinguish them.

    To make a DeltaRPM, use these commands that come with the RPM suite.

    Code:
    prepdeltarpm -s seq -i info OLD.rpm > old.cpio
    prepdeltarpm -f NEW.rpm > new.cpio
    xdelta delta -0 old.cpio new.cpio delta
    writedeltarpm NEW.rpm delta info NEW.delta.rpm
    rm old.cpio new.cpio delta #remove temporary files
    
    "OLD.rpm" and "NEW.rpm" are to packages of a particular software where "NEW.rpm" is the newer version. "NEW.delta.rpm" is the DeltaRPM file.


    SRPM:

    To use SRPM files (source code), obtain the SRPM file and use this command to compile the code -

    rpmbuild --rebuild <PACKAGE>.src.rpm

    This will make a regular RPM file which can be installed like any RPM file.


    Knowing these commands will be helpful when managing RedHat-based systems. Even though Debian-based systems are more popular, it is still very important to understand other distros and their structure.

    For further reading about an upcoming package manager - https://fedoraproject.org/wiki/Features/DNF (thanks G+ followers (Nik Th especially) for this link)

    Attached Files:

    • slide.jpg
      slide.jpg
      File size:
      23.5 KB
      Views:
      112,041
    Last edited: Aug 9, 2014
  2. DevynCJohnson

    DevynCJohnson Well-Known Member Staff Member Staff Writer

    Messages:
    1,336
    Likes Received:
    1,074
    Trophy Points:
    113
    I have applied some minor tweaks to this article.

Share This Page