FreeKB - Install and update packages using the YUM command in Linux
Install and update packages using the YUM command in Linux

Home > Search > Linux commands


The /etc/yum.repos.d/ directory should contain one or more repository files, suc as:

  • CentOS-Base.repo
  • CentOS-Media.repo
  • CentOS-Vault.repo 

Each repo files will contain the title of the repo in brackets, the name of the repo, the mirror or base URL of the repo., and 1 for enabled or 0 for not enabled For example, near the beginning of the CentOS-Base.repo is the following markup.

name=CentOS-$releasever - Base


Navigating to the mirror or base URL will produce a list of URLs, and each of these URLs will contains packages that can be downloaded and installed using yum.


For example, let's say you want to install the httpd web server. When using yum to install httpd, the yum command will use the mirror or base URL to get the list of repositories that can be used, and if one of the repositories contains the httpd package, then yum will be able to install the httpd package.


The yum repolist all command can be used to list the status of your repos.

~]# yum repolist all
repo id
!base/7/x86_86       CentOS-7.0.1406    enabled
!epel/x86_64         CentOS-7.0.1406    enabled
!updates/7/x86_64    CentOS-7.0.1406    enabled
base-source/7        CentOS-7.0.1406    disabled


Repos can be permanently enabled using the --enable option, or permanently disabled using the --disable option.

~]# yum-config-manager --enable epel


Repos can temporarily be enabled using --enablerepo, or temporarily disabled using --disablerepo.

~]# yum --enablerepo=epel install package_name


Find a package

The following commands will display information about a package, regardless if the package is or is not installed on the system. 

If you do not know the exact name of a package,  the yum search package_name command can be used to search for a package.

~]# yum search httpd
Loaded plugins: fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Determing fastest mirrors * base: * 
extras: * 
====================================== N/S matches: httpd =================
libmicrohttpd-devel.i686 : Development files for libmicrohttpd
libmicrohttpd-devel.x86_64 : Development files for libmicrohttpd
libmicrohttpd-doc.noarch : Documentation for libmicrohttpd
httpd.x86_64 : Apache HTTP Server
httpd-devel.x86_64 : Development interfaces for the Apache HTTP server


The yum info package_name command can also be used to list both installed and available packages. This will only display a brief description of the package. 

~]# yum info httpd
Installed Packages
httpd.x86_64           2.4.6-45.el7.centos.4               @updates


Yum group info package_name can be used to display information on a group package. 

~]# yum group info package_name


The yum info package_name command can also be used to view information about a package.

~]# yum info httpd
Installed Packages
Name        : httpd
Arch        : x86_64
Version     : 2.4.6
Release     : 45.el7.centos.4
Size        : 9.4 M
Repo        : installed
From repo   : updates
Summary     : Apache HTTP Server
URL         :
License     : ASL 2.0
Description : The Apache HTTP Server is a powerful, efficient, and exensible
            : web server.


Yum provides file_name can be used to determine the package that provides a certain file. 

~]# yum provides /path/to/file


Install a package 

The yum install package_name command can be used to install a package.

~]# yum install httpd


Package groups can also be installed. Double quotes must be used if there is a space in the group name.

~]# yum group install "group name"
~]# yum group install group-name


Download a package 

The yumdownloader command can be used to download but not install a package. The yumdownloader command is included in the yum-utils package. Install yum-utils.

~]# yum install yum-utils


After yum-utils is installed, the yumdownloader command can be used. For example, yumdownloader httpd downloads the HTTPD package.

~]# yumdownloader httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached host
file * base: * extras: * updates:


The --destdir option can be used to specify a directory other than the present working directory.

~]# yumdownloader --destdir /home/<username>/Downloads httpd


Notice the last line in the yumdownloader output lists the HTTPD RPM. The LS command can be used to verify that the RPM was downloaded.

~]# ls


Once the RPM has been downloaded, the RPM -i httpd-version.rpm command can be used to install the package.

~]# rpm -i httpd-version.rpm
~]# rpm --install httpd-version.rpm


Update a package 

The update option updates a package.

~]# yum update package_name


Remove a package 

The remove or erase option will uninstall a package, but not remove the configuration files. There is no difference between remove and erase.

~]# yum remove package_name
~]# yum erase package_name


Add group to remove a group package. 

~]# yum group remove "group name"


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.