RPM & YUM Commands with Examples for RHEL 7 / CentOS 7

Package Management (RPM & YUM) Commands for RHEL and Fedora Based Linux Distributions

Redhat Package Manager (RPM)

  • RPM is both a installation method as well as a package format.
  • RPM packages were original created of Red Hat Linux, but now can be used on many Linux distributions like
  • red Hat enterprise Linux, fedora, SUSE, Mandriva, etc.
  • Using RPM we can
  • Install new applications
  • Upgrade existing applications
  • Remove installed applications
  • Query packages
RPM Label Pattern
Bind-9.3.3-7.el5.i386.rpm

this examples is given by using following format

(Package Name)-(Package Version)-(Package Architecture)-(Package Extension)

Methods of Installation
  • Standalone Method
  • Installing from a Harddisk, CD, DVD or Pendrive
  • Network Installation Method
  • Network file service (NFS).
  • File transfer Protocol(FTP).
Standalone Installation
Installing a package
[[email protected]~]# rpm <options> <package name>  --force
Options

-I             install                                                    -U           Update existing package

-v            Verbose                                               –force  Install the package forcefully

-h            Displays the progress in hashes

 

Removing  an Installed Package
Removing a Package
[[email protected]~]# rpm <options> <package name> --nodeps

Options

-e                            Erase (uninstall)

–nodeps             Uninstall the package even if other applications are dependent on this application

Querying an Installation
Installing a package
[[email protected]~]# rpm <options ><Package name>

Options

-q            Query the availability of the package

-qa         Displays all installed packages

-qc          Displays the configuration files of the package

-qi           Displays the information of the package

-ql           Displays all the files associated with the installed package

Network Installation Method – NFS
Create a directory
[[email protected]~]# mkdir <directory name>
Mount the NFS fie system on the directory
[[email protected]~]# mount <NFSservip>:<path to the package> <mount Point>
To install the package
[[email protected]~]# cd <mount point>
[[email protected]~]# rpm <option><package>  --force
Network Installation Method –FTP
To install the package
[[email protected]~]# rpm <options> ftp://<FTPserver><path > --force

Yellowdog Updater Modification (YUM)

  • It is an interactive use to Install, Remove, upgrade or qury the packages.
  • Added from RHEL 5 onwards.
  • YUM uses an repository that is xml-based rpm metadata for installation.
  • It automatically computes dependencies and figures out what things should occur to install packages.
  • It can be used to installed from a local media, ftp server or nfs server.
To create a Respository
On the local machine
  • Create a directory.
  • Copy the packages into this directory.
  • Install the package createrepo*.rpm.
  • Insert the 1st OS cd
  • Create the respository.
Creating the repository
[[email protected]~]# createrepo –g /media/cdrom/Server/repodate/comps-rhel5-server-core.xml <directory>
Client Configuration
To define the path to the repository
[[email protected]~]# vi/etc/yum.repos.d/rhel-debuginfo.repo

Add the following lines

[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever-$basearch- debug
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasver/en/os/$basearch/Debuginfo
enable=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

:wq

Client Configuration
For local machine- change the highlighted line to
baseurl=file:///<path to the directory containing the dumps>
Through ftp – change the highlighted line to
Baseurl=ftp://<ftpserver><path to the directory containing the dumps>
YUM Command
Installing a package
[[email protected]~]# yum <option> <package name1>* <package name2>*

Options

List                         Display the list of packages in the repository.

List installed       Displays the packages that are already installed.

Remove               To erase or remove a packages.

Install                    Installs the package from the respository.

Update                 To update existing packages.

Congratulations now you have learned Package Management (RPM & YUM) Commands for RHEL and Fedora Based Linux Distributions. 

Related Post

Develop New SysAdmin Skills with E-books (FREE Download)

COMMENTS