yum vs rpm
The major differences between YUM and RPM are that
To install an RPM package, we use of the
===============================
YUM
yum
knows how to resolve dependencies and can source these additional packages when doing its work. Though rpm
can alert you to these dependencies, it is unable to source additional packages.To install an RPM package, we use of the
-i
flag. # rpm -ivh kernel-2.4.21-15.0.3.EL.i686.rpm
Preparing... ########################################### [100%]
1:kernel ########################################### [100%]
To upgrade an RPM package, we use of the -U
flag# rpm -Uvh httpd-2.0.46-32.ent.3.i386.rpm mod_ssl-2.0.46-32.ent.3.i386.rpm
Preparing... ########################################### [100%]
1:httpd ########################################### [ 50%]
2:mod_ssl ########################################### [100%]
# rpm -q httpd; rpm -q mod_ssl
httpd-2.0.46-32.ent.3
mod_ssl-2.0.46-32.ent.3
Note: The
httpd
and mod_ssl
needed to be installed at the same time because of dependency issues. If you try to install one without the other, you would get an error similar to the following:# rpm -Uvh httpd-2.0.46-32.ent.3.i386.rpm
error: Failed dependencies:
httpd = 2.0.46-32.ent is needed by (installed) mod_ssl-2.0.46-32.ent
How to Install an RPM Package
RPM command and options
- -i : install a package
- -v : verbose for a nicer display
- -h: print hash marks as the package archive is unpacked.
How to check dependencies of RPM Package before Installing
Let’s say you would like to do a dependency check before installing or upgrading a package. For example, use the following command to check the dependencies of BitTorrent-5.2.2-1-Python2.4.noarch.rpm package. It will display the list of dependencies of package.
RPM command and options
- -q : Query a package
- -p : List capabilities this package provides.
- -R: List capabilities on which this package depends..
How to Install a RPM Package Without Dependencies
If you know that all needed packages are already installed and RPM is just being stupid, you can ignore those dependencies by using the option –nodeps (no dependencies check) before installing the package.
How to check an Installed RPM Package
Using -q option with package name, will show whether an rpm installed or not.
How to List all files of an installed RPM package
To view all the files of an installed rpm packages, use the -ql (query list) with rpm command.
How to List Recently Installed RPM Packages
Use the following rpm command with -qa (query all) option, will list all the recently installed rpm packages.
How to List All Installed RPM Packages
Type the following command to print the all the names of installed packages on your Linux system.
How to Upgrade a RPM Package
If we want to upgrade any RPM package “–U” (upgrade) option will be used. One of the major advantages of using this option is that it will not only upgrade the latest version of any package, but it will also maintain the backup of the older package so that in case if the newer upgraded package does not run the previously installed package can be used again.
How to Remove a RPM Package
To un-install an RPM package, for example we use the package name nx, not the original package name nx-3.5.0-2.el6.centos.i686.rpm. The -e (erase) option is used to remove package.
How to Remove an RPM Package Without Dependencies
The –nodeps (Do not check dependencies) option forcefully remove the rpm package from the system. But keep in mind removing particular package may break other working applications.
How to Query a file that belongs which RPM Package
Let’s say, you have list of files and you would like to find out which package belongs to these files. For example, the following command with -qf (query file) option will show you a file /usr/bin/htpasswd is own by package httpd-tools-2.2.15-15.el6.centos.1.i686.
How to Query a Information of Installed RPM Package
Let’s say you have installed an rpm package and want to know the information about the package. The following -qi (query info) option will print the available information of the installed package.
Get the Information of RPM Package Before Installing
You have download a package from the internet and want to know the information of a package before installing. For example, the following option -qip (query info package) will print the information of a package sqlbuddy.
How to Query documentation of Installed RPM Package
To get the list of available documentation of an installed package, use the following command with option -qdf (query document file) will display the manual pages related to vmstat package.
How to Verify a RPM Package
Verifying a package compares information of installed files of the package against the rpm database. The -Vp (verify package) is used to verify a package.
How to Verify all RPM Packages
Type the following command to verify all the installed rpm packages.
How to Import an RPM GPG key
To verify RHEL/CentOS/Fedora packages, you must import the GPG key. To do so, execute the following command. It will import CentOS 6 GPG key.
How to List all Imported RPM GPG keys
To print all the imported GPG keys in your system, use the following command.
How To rebuild Corrupted RPM Database
Sometimes rpm database gets corrupted and stops all the functionality of rpm and other applications on the system. So, at the time we need to rebuild the rpm database and restore it with the help of following command.
===============================
YUM
Install a Package with YUM
To install a package called Firefox 14, just run the below command it will automatically find and install all required dependencies for Firefox.
To remove a package completely with their all dependencies, just run the following command as shown below.
Updating a Package using YUM
Let’s say you have outdated version of MySQL package and you want to update it to the latest stable version. Just run the following command it will automatically resolves all dependencies issues and install them.
List a Package using YUM
Use the list function to search for the specific package with name. For example to search for a package called openssh, use the command.
Search for a Package using YUM
If you don’t remember the exact name of the package, then use search function to search all the available packages to match the name of the package you specified. For example, to search all the packages that matches the word .
Get Information of a Package using YUM
Say you would like to know information of a package before installing it. To get information of a package just issue the below command.
List all Available Packages using YUM
To list all the available packages in the Yum database, use the below command.
List all Installed Packages using YUM
To list all the installed packages on a system, just issue below command, it will display all the installed packages.
Yum Provides Function
Yum provides function is used to find which package a specific file belongs to. For example, if you would like to know the name of the package that has the /etc/httpd/conf/httpd.conf.
Check for Available Updates using Yum
To find how many of installed packages on your system have updates available, to check use the following command.
Update System using Yum
To keep your system up-to-date with all security and binary package updates, run the following command. It will install all latest patches and security updates to your system.
List all available Group Packages
In Linux, number of packages are bundled to particular group. Instead of installing individual packages with yum, you can install particular group that will install all the related packages that belongs to the group. For example to list all the available groups, just issue following command.
Install a Group Packages
To install a particular package group, we use option as groupinstall. Fore example, to install “MySQL Database“, just execute the below command.
Update a Group Packages
To update any existing installed group packages, just run the following command as shown below.
List Enabled Yum Repositories
To list all enabled Yum repositories in your system, use following option.
List all Enabled and Disabled Yum Repositories
The following command will display all enabled and disabled yum repositories on the system.
Install a Package from Specific Repository
To install a particular package from a specific enabled or disabled repository, you must use –enablerepo option in your yum command. For example to Install PhpMyAdmin 3.5.2 package, just execute the command.
Clean Yum Cache
By default yum keeps all the repository enabled package data in /var/cache/yum/ with each sub-directory, to clean all cached files from enabled repository, you need to run the following command regularly to clean up all the cache and make sure that there is nothing unnecessary space is using. We don’t want to give the output of the below command, because we like to keep cached data as it is.
View History of Yum
To view all the past transactions of yum command, just use the following command.
List all available yum packages
To list all packages that are available to you using the
yum
command, use the yum list
command:yum list all
That should be a long list, so you'll probably want to pipe that into
more
or grep
, like this:yum list all | more
or this:
yum list all | grep -v installed | more
List installed yum packages
To list all installed packages use the yum list installed command:
yum list installed
or
yum list installed | more
See if an individual yum package is installed
To see if a particular package is installed the yum list command is still good. On my test server this command:
yum list mysql
Comments
Post a Comment