This is not an exhaustive list of all yum commands but it is a list of the basic/common/important ones. For a complete list see the yum man page.
List packages in the repositories
List all packages in all the repositories.
yum list all
List all the packages available to be installed in any enabled repository of your system.
yum list available
List all packages installed in your system.
yum list installed
List already installed packages that have updates available.
yum list updatesOR
List any package added to any enabled repository in the last 7 days.
yum list recent
Install or update packages
To install a package use the following syntax.
yum install <package name[s]>
For example, to install Gedit and Rsync, do the following -
yum install gedit rsync
Update all the packages installed on your system
Update just an individual package (say gedit)
yum update gedit
If the gedit package installed on your system is the current version, yum will not do anything.
Display information about a package
To get additional information about a specific package without actually installing it, you use the following Yum command.
yum info <package name>
It gives the following information about the package - Name, Arch , Version, Release, Size, whether installed or not, Summary, Home page URL, License, and Description.
For example, to find more about gedit package, do the following.
yum info gedit
Search for packages
yum search <package name[s]>
As an example, you can search for multiple packages as follows :
yum search gedit rsync ssh
The search option also accepts wild card characters in the event you need to utilize them. To know more about using wild cards read the Regular Expressions tutorial.
Search for a package that provides a dependency for a particular file.
yum provides <package name[s]>
yum whatprovides <package name[s]>
For example, if you need a certain library which is not a standalone package, say - libc6.1-1.so.2; You can use the above Yum syntax to search in which package, the particular library is in:
yum provides libc6.1-1.so.2
To remove a package the Yum syntax is -
yum remove <package name[s]>
For example, to remove Gedit, you do the following -
yum remove gedit
This removes the selected package as well as any other package that depends on it.
Flush the package cache
One thing worth noting is that when Yum downloads packages or updates for installation it does not remove them automatically from its disk cache, so some periodic maintenance is required. This is achieved as shown below.
yum clean [all|packages|metadata|dbcache]
For example, to clean all cached files from any enabled repository, run the following command -
yum clean all
It is useful to run the above command from time to time to make sure there is nothing using unnecessary space.