• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • 15 practical examples of rpm command usage in Linux

    I have written a blog explaining different fields of an rpm. To understand a rpm and all its fields follow the below link
    Understanding RPM package

    Here I have tried to summarize a list of rpm commands which can be helpful.

    1. Install a new package# rpm -ivh gcc-4.3-62.198.x86_64.rpm
    Preparing...                ########################################### [100%]
       1:gcc                    ########################################### [100%]


    2. Forcefully install a package# rpm -ivh gcc-4.3-62.198.x86_64.rpm
    Preparing...                ########################################### [100%]
            package gcc-4.3-62.198.x86_64 is already installed

    As you see since gcc rpm is already installed the installation does not completes so for such situations use should use --force switch as seen below
    # rpm -ivh gcc-4.3-62.198.x86_64.rpm --force
    Preparing...                ########################################### [100%]
       1:gcc                    ########################################### [100%]


    3. Upgrade a package# rpm -Uvh gcc-4.3-62.200.2.x86_64.rpm
    Preparing...                ########################################### [100%]
       1:gcc                    ########################################### [100%]


    4. Un-install a package
    To uninstall an rpm you need the exact name of the rpm which has to be installed. For eg if you have to uninstall gcc43-c++ then in case you run the below command to remove this





    # rpm -e gcc43-c
    error: package gcc43-c is not installed

    As you see you should provide complete name # rpm -e gcc-c++
    # echo $?
    0


    5. Install/Un-install a package without dependencies
    Make sure you are fully aware before you use this option since there is a probability that the package won't function properly if the dependencies are not installed. Although you can skip the same using --nodeps
    # rpm -ivh kiwi-instsource-5.05.25-616.1.x86_64.rpm
    warning: kiwi-instsource-5.05.25-616.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID d3668a00
    error: Failed dependencies:
            build is needed by kiwi-instsource-5.05.25-616.1.x86_64

    # rpm -ivh kiwi-instsource-5.05.25-616.1.x86_64.rpm --nodeps
    warning: kiwi-instsource-5.05.25-616.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID d3668a00
    Preparing...                ########################################### [100%]
       1:kiwi-instsource        ########################################### [100%]

    To remove a package you can use the same option



    # rpm -e kiwi-tools-5.05.25-616.1
    error: Failed dependencies:
            kiwi-tools >= 5.05.25 is needed by (installed) kiwi-5.05.25-616.1.x86_64

    # rpm -e kiwi-tools-5.05.25-616.1 --nodeps

    Alternatively you can also use --force along with --nodeps

    6. Display the Package's File List
    Adding -l to rpm -q tells RPM to display the list of files that are installed by the specified package or packages.
    # rpm -ql gcc
    /usr/bin/cc
    /usr/bin/gcc
    /usr/bin/gcov
    /usr/share/man/man1/cc.1.gz
    /usr/share/man/man1/gcc.1.gz
    /usr/share/man/man1/gcov.1.gz


    7. Display the Package's File List for non-installed rpm

    To check this make sure you have access to the rpm of which the content has to be checked
    # rpm -qlp squashfs-4.0-2.1.x86_64.rpm
    warning: squashfs-4.0-2.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 29b4acdd
    /usr/bin/mksquashfs
    /usr/bin/unsquashfs
    /usr/share/doc/packages/squashfs
    /usr/share/doc/packages/squashfs/CHANGES
    /usr/share/doc/packages/squashfs/PERFORMANCE.README
    /usr/share/doc/packages/squashfs/README
    /usr/share/doc/packages/squashfs/README-4.0





    8. Display Package's File List with Additional Information# rpm -qlv gcc
    lrwxrwxrwx 1 root root 7 Feb 21 2009 /usr/bin/cc -> gcc-4.3
    lrwxrwxrwx 1 root root 7 Feb 21 2009 /usr/bin/gcc -> gcc-4.3
    lrwxrwxrwx 1 root root 8 Feb 21 2009 /usr/bin/gcov -> gcov-4.3
    lrwxrwxrwx 1 root root 12 Feb 21 2009 /usr/share/man/man1/cc.1.gz -> gcc-4.3.1.gz
    lrwxrwxrwx 1 root root 12 Feb 21 2009 /usr/share/man/man1/gcc.1.gz -> gcc-4.3.1.gz
    lrwxrwxrwx 1 root root 13 Feb 21 2009 /usr/share/man/man1/gcov.1.gz -> gcov-4.3.1.gz


    9. Query the Package Owning <file>
    There might be a case when you know a file like /usr/bin/sudo but you are not sure which rpm is responsible for installing this file. Use -qf along with rpm command for such cases.

    NOTE: The below command is only useful if the file you are querying for is present in your machine
    # rpm -qf /usr/bin/sudo
    sudo-1.7.6p2-0.17.5


    10. Display a List of the Package's Documentation
    When -d is added to a query, we get a list of all files containing documentation for the named package or packages. This is a great way to get up to speed when you're having problems with unfamiliar software. As with -c and -l, you'll see either a simple list of filenames, or (if you've added -v) a more comprehensive list.
    # rpm -qd gawk
    /usr/share/doc/packages/gawk/AUTHORS
    /usr/share/doc/packages/gawk/COPYING
    /usr/share/doc/packages/gawk/FUTURES
    /usr/share/doc/packages/gawk/LIMITATIONS
    /usr/share/doc/packages/gawk/NEWS
    /usr/share/doc/packages/gawk/POSIX.STD
    /usr/share/doc/packages/gawk/PROBLEMS
    /usr/share/doc/packages/gawk/README
    /usr/share/info/gawk.info.gz
    /usr/share/info/gawkinet.info.gz
    /usr/share/man/man1/awk.1.gz
    /usr/share/man/man1/gawk.1.gz
    /usr/share/man/man1/igawk.1.gz
    /usr/share/man/man1/pgawk.1.gz


    11. Display the Package's List of Configuration Files

    When -c is added to an rpm -q command, RPM will display the configuration files that are part of the specified package or packages.
    # rpm -qc netcfg
    /etc/HOSTNAME
    /etc/aliases
    /etc/defaultdomain
    /etc/ethers
    /etc/exports
    /etc/ftpusers
    /etc/host.conf
    /etc/hosts
    /etc/hosts.allow
    /etc/hosts.deny
    /etc/hosts.equiv


    12. Query the Packages That Provide Capability
    RPM provides extensive support for dependencies between packages. The basic mechanism used is that a package may require what another package provides.
    # rpm -q --whatprovides gcc
    gcc-4.3-62.198




    13. Display Package Information
    # rpm -qi kernel-default-base
    Name        : kernel-default-base          Relocations: (not relocatable)
    Version     : 3.0.101                           Vendor: SUSE LINUX Products GmbH, Nuernberg, Germany
    Release     : 0.46.1                        Build Date: Wed Dec 17 09:19:54 2014
    Install Date: Fri Jun 12 05:31:11 2015         Build Host: sheep03
    Group       : System/Kernel                 Source RPM: kernel-default-3.0.101-0.46.1.nosrc.rpm
    Size        : 23896685                         License: GPL v2 only
    Signature   : RSA/8, Wed Dec 17 09:22:49 2014, Key ID e3a5c360307e3d54
    Packager    : http://bugs.opensuse.org
    URL         : http://www.kernel.org/
    Summary     : The Standard Kernel - base modules
    Description :
    The standard kernel for both uniprocessor and multiprocessor systems.

    This package contains only the base modules, required in all installs.

    Source Timestamp: 2014-12-17 12:04:10 +0100
    GIT Revision: 8356111faa769f649b6d7c8b5bcbb34fb17120aa
    GIT Branch: SLE11-SP3-CVE-2014-9322
    Distribution: SUSE Linux Enterprise 11


    14. Display Capabilities Provided by the Package
    By adding "--provides" to a query command, we can see the capabilities provided by one or more packages. If the package doesn't provide any capabilities, the --provides option produces no output:

    # rpm -q gcc --provides
    c_compiler
    gcc = 4.3-62.198


    15. Query All Installed Packages
    Using the -a option, you can query every package installed on your system. For example:
    # rpm -qa | grep kernel
    kernel-default-devel-3.0.76-0.11.1
    kernel-firmware-20110923-0.42.49
    kernel-source-3.0.76-0.11.1
    linux-kernel-headers-2.6.32-1.13.5
    kernel-default-3.0.101-0.46.1
    kernel-default-base-3.0.101-0.46.1
    kernel-default-extra-3.0.101-0.46.1
    15 practical examples of rpm command usage in Linux 15 practical examples of rpm command usage in Linux Reviewed by admin on Sunday, October 25, 2015 Rating: 5

    2 comments:

    Powered by Blogger.