YUM (Yellowdog Updater Modified) is an open source command-line as well as graphical based package management tool for RPM (RedHat Package Manager) based Linux systems. It allows users and system administrator to easily install, update, remove or search software packages on a systems. YUM uses numerous third party repositories to install packages automatically by resolving their dependencies issues.
YUM Repository Configuration File
We can install new software on Red Hat/CentOS Linux with "yum install packagename" command from console. Running this command first checks for existing YUM Repository configuration files in /etc/yum.repos.d/ directory. It reads each YUM Repository configuration file to get the information required to download and install new software, resolves software dependencies and installs the required RPM package files.
YUM Repository configuration files must: be located in /etc/yum.repos.d/ directory
have .repo extension, to be recognized by YUM. Available YUM Repository configuration file options are:
Repository ID - One word unique repository ID (example: [examplerepo])
Name - Human readable name of the repository (example: name=Example Repository)
Baseurl - URL to the repodata directory. You can use file://path if repository is located locally or ftp://link, http://link, https://link if repository is located remotely - HTTP Authentication available http://user:password@www.repo1.com/repo1 (example: baseurl=http://mirror.cisp.com/CentOS/6/os/i386/)
Enabled - Enable repository when performing updates and installs (example: enabled=1)
Gpgcheck - Enable/disable GPG signature checking (example: gpgcheck=1)
Gpgkey - URL to the GPG key (example: gpgkey=http://mirror.cisp.com/CentOS/6/os/i386/RPM-GPG-KEY-CentOS-6)
Exclude - List of the packages to exclude (example: exclude=httpd,mod_ssl)
Includepkgs - List of the packages to include (example: include=kernel)
Required YUM Repository configuration file options are:
Repository ID
Name
Baseurl
Enabled
Step 1: Create YUM Repository configuration file
Use your favorite console text editor and create a new YUM Repository configuration file with .repo extension in /etc/yum.repos.d/ directory. To create a new file with "vi editor" run the following command from console:
vi /etc/yum.repos.d/example.repo
Step 2: Insert YUM Repository options
Insert the desired YUM Repository options to the newly created YUM Repository configuration file and save changes.
Example YUM Repository Configuration file:
/etc/yum.repos.d/example.repo
[examplerepo]
name=Example Repository
baseurl=http://mirror.cisp.com/CentOS/6/os/i386/
enabled=1
gpgcheck=1
gpgkey=http://mirror.cisp.com/CentOS/6/os/i386/RPM-GPG-KEY-CentOS-6
1. Install a Package with YUM
To install a package called Firefox , just run the below command it will automatically find and install all required dependencies for Firefox.
#yum install firefox
The above command will ask confirmation before installing any package on your system. If you want to install packages automatically without asking any confirmation, use option -y as shown in below example.
#yum -y install firefox
2. Removing a Package with YUM
To remove a package completely with their all dependencies, just run the following command as shown below.
# yum remove firefox
3. 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.
# yum update mysql
4. 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.
# yum list openssh
To make your search more accurate, define package name with their version, in case you know. For example to search for a specific version openssh-4.3p2 of the package, use the command.
# yum list openssh-4.3p2
5. 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 .
# yum search vsftpd
6. 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.
# yum info firefox
7. List all Available Packages using YUM
To list all the available packages in the Yum database, use the below command.
# yum list | less
8. 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 list installed | less
9. 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.
# yum provides /etc/httpd/conf/httpd.conf
10. 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.
# yum check-update
11. 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.
# yum update
12. 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.
# yum grouplist
13. 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.
# yum groupinstall 'MySQL Database'
YUM Repository Configuration File
We can install new software on Red Hat/CentOS Linux with "yum install packagename" command from console. Running this command first checks for existing YUM Repository configuration files in /etc/yum.repos.d/ directory. It reads each YUM Repository configuration file to get the information required to download and install new software, resolves software dependencies and installs the required RPM package files.
YUM Repository configuration files must: be located in /etc/yum.repos.d/ directory
have .repo extension, to be recognized by YUM. Available YUM Repository configuration file options are:
Repository ID - One word unique repository ID (example: [examplerepo])
Name - Human readable name of the repository (example: name=Example Repository)
Baseurl - URL to the repodata directory. You can use file://path if repository is located locally or ftp://link, http://link, https://link if repository is located remotely - HTTP Authentication available http://user:password@www.repo1.com/repo1 (example: baseurl=http://mirror.cisp.com/CentOS/6/os/i386/)
Enabled - Enable repository when performing updates and installs (example: enabled=1)
Gpgcheck - Enable/disable GPG signature checking (example: gpgcheck=1)
Gpgkey - URL to the GPG key (example: gpgkey=http://mirror.cisp.com/CentOS/6/os/i386/RPM-GPG-KEY-CentOS-6)
Exclude - List of the packages to exclude (example: exclude=httpd,mod_ssl)
Includepkgs - List of the packages to include (example: include=kernel)
Required YUM Repository configuration file options are:
Repository ID
Name
Baseurl
Enabled
Step 1: Create YUM Repository configuration file
Use your favorite console text editor and create a new YUM Repository configuration file with .repo extension in /etc/yum.repos.d/ directory. To create a new file with "vi editor" run the following command from console:
vi /etc/yum.repos.d/example.repo
Step 2: Insert YUM Repository options
Insert the desired YUM Repository options to the newly created YUM Repository configuration file and save changes.
Example YUM Repository Configuration file:
/etc/yum.repos.d/example.repo
[examplerepo]
name=Example Repository
baseurl=http://mirror.cisp.com/CentOS/6/os/i386/
enabled=1
gpgcheck=1
gpgkey=http://mirror.cisp.com/CentOS/6/os/i386/RPM-GPG-KEY-CentOS-6
1. Install a Package with YUM
To install a package called Firefox , just run the below command it will automatically find and install all required dependencies for Firefox.
#yum install firefox
The above command will ask confirmation before installing any package on your system. If you want to install packages automatically without asking any confirmation, use option -y as shown in below example.
#yum -y install firefox
2. Removing a Package with YUM
To remove a package completely with their all dependencies, just run the following command as shown below.
# yum remove firefox
3. 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.
# yum update mysql
4. 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.
# yum list openssh
To make your search more accurate, define package name with their version, in case you know. For example to search for a specific version openssh-4.3p2 of the package, use the command.
# yum list openssh-4.3p2
5. 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 .
# yum search vsftpd
6. 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.
# yum info firefox
7. List all Available Packages using YUM
To list all the available packages in the Yum database, use the below command.
# yum list | less
8. 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 list installed | less
9. 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.
# yum provides /etc/httpd/conf/httpd.conf
10. 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.
# yum check-update
11. 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.
# yum update
12. 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.
# yum grouplist
13. 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.
# yum groupinstall 'MySQL Database'
14. Update a Group Packages
To update any existing installed group packages, just run the following command as shown below.
# yum groupupdate 'DNS Name Server'
15. Remove a Group Packages
To delete or remove any existing installed group from the system, just use below command.
# yum groupremove 'DNS Name Server'
16. List Enabled Yum Repositories
To list all enabled Yum repositories in your system, use following option.
# yum repolist
16. List all Enabled and Disabled Yum Repositories
The following command will display all enabled and disabled yum repositories on the system.
# yum repolist all
17. 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.
# yum --enablerepo=epel install phpmyadmin
18. Interactive Yum Shell
Yum utility provides a custom shell where you can execute multiple commands.
# yum shell
19. 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.
# yum clean all
20. View History of Yum
To view all the past transactions of yum command, just use the following command.
# yum history
List of Commands:
check Check for problems in the rpmdb
check-update Check for available package updates
clean Remove cached data
deplist List a package's dependencies
distribution-synchronization Synchronize installed packages to the latest available versions
downgrade downgrade a package
erase Remove a package or packages from your system
groupinfo Display details about a package group
groupinstall Install the packages in a group on your system
grouplist List available package groups
groupremove Remove the packages in a group from your system
help Display a helpful usage message
history Display, or use, the transaction history
info Display details about a package or group of packages
install Install a package or packages on your system
list List a package or groups of packages
load-transaction load a saved transaction from filename
makecache Generate the metadata cache
provides Find what package provides the given value
reinstall reinstall a package
repolist Display the configured software repositories
resolvedep Determine which package provides the given dependency
search Search package details for the given string
shell Run an interactive yum shell
update Update a package or packages on your system
upgrade Update packages taking obsoletes into account
version Display a version for the machine and/or available repos.