YUM commands to Manage Packages on RHEL based systems

As per my experience in Linux administration i can assure, we can’t manage RHEL /CentOS /Fedora /Scientific Linux systems without YUM Command. It is mandatory to perform so many actions. Yum (Yellowdog Updater Modified) is one of the package manager utility in Linux operating system. Yum command is used to install, update, search & remove packages on some Linux distributions based on RedHat. Some other package manger utilities which are being used widely in Linux are apt-get, dpkg, rpm, Zypper, pacman, etc.,

Now, I’m going to play on my CentOS 6.6 server to explain and cover mostly used yum commands with examples. Reference link

1) Common syntax/file location for yum

See below for common syntax/ file location of yum.

# Common syntax for yum #
[email protected] [~]# yum [options] [commands] [package name]

# most popular yum commands #
[email protected] [~]# [install remove update search info check-update clean repolist list history

# yum Repository file location #
[email protected] [~]# /etc/yum.repos.d

# yum cached file location #
[email protected] [~]# /var/cache/yum

2) Install a Package or packages

Use the below command to install any package or packages on your system. In this case i’m going to install apache, MariaDB-server, MariaDB-client. Every time yum ask your confirmation to install the corresponding package. if you want to avoid the confirmation you can do by this adding -y option with yum.

# Install a single package #
[email protected] [~]# yum install httpd
or
[email protected] [~]# yum -y install httpd

# Install more than one packages #
[email protected] [~]# yum install MariaDB-server MariaDB-client
or
[email protected] [~]# yum -y install MariaDB-server MariaDB-client

3) Remove a Package or packages

Use the below command to remove/erase any package or packages on your system. In this case I’m going to remove apache, MariaDB-server, MariaDB-client.

# Remove a single package #
[email protected] [~]# yum remove httpd
or
[email protected] [~]# yum erase httpd

# Remove more than one packages #
[email protected] [~]# yum remove MariaDB-server MariaDB-client
or
[email protected] [~]# yum erase MariaDB-server MariaDB-client

4) update a Package or packages

Use the below command to update any package or packages on your system. In this case I’m going to update apache, MariaDB-server, MariaDB-client to latest version.

# update single package #
[email protected] [~]# yum update httpd

# update more than one packages #
[email protected] [~]# yum update MariaDB-server MariaDB-client

5) list all repository packages

Use the below command to list all packages which are available in all repository. I have enabled EPEL & REMI so in this case it shows all the repository packages. Both gives same results.

[email protected] [~]# yum list
or
[email protected] [~]# yum list all

6) Check updates

Use the below command to check available package updates on your system. In this case kernel update is available. Both gives same results.

[email protected] [~]# yum list updates
or
[email protected] [~]# yum check-update
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos.hyve.com
 * epel: mirrors.coreix.net
 * extras: centos.hyve.com
 * rpmforge: www.mirrorservice.org
 * updates: mirror.sov.uk.goscomb.net

kernel.x86_64                                                     2.6.32-504.3.3.el6                                                     updates

7) list installed packages

Use the below command to print installed packages on your Linux system.

[email protected] [~]# yum list installed

8) Search a package

If you don’t know the exact package name which you want to install, Use the search option it will return the matching string. In this case I’m going to search ftpd

[email protected] [~]# yum search ftpd
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos.hyve.com
 * epel: mirrors.coreix.net
 * extras: centos.hyve.com
 * rpmforge: www.mirrorservice.org
 * updates: mirror.sov.uk.goscomb.net
============================================================== N/S Matched: ftpd ===============================================================
nordugrid-arc-gridftpd.x86_64 : ARC gridftp server
pure-ftpd.x86_64 : Lightweight, fast and secure FTP server
vsftpd.x86_64 : Very Secure Ftp Daemon

  Name and summary matches only, use "search all" for everything.

The above output shows matching string for ftpd

9) Check package information

If you want to know the package detailed information before proceeding with the installation. Use the below command, it will give full information about the package like package version, size, repo name, etc..

[email protected] [~]# yum info vsftpd
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos.hyve.com
 * epel: mirrors.coreix.net
 * extras: mirrors.coreix.net
 * rpmforge: www.mirrorservice.org
 * updates: mirror.sov.uk.goscomb.net
Available Packages
Name        : vsftpd
Arch        : x86_64
Version     : 2.2.2
Release     : 13.el6_6.1
Size        : 151 k
Repo        : updates
Summary     : Very Secure Ftp Daemon
URL         : http://vsftpd.beasts.org/
License     : GPLv2 with exceptions
Description : vsftpd is a Very Secure FTP daemon. It was written completely from
            : scratch.

10) How to Check package is installed or not

Use the below command to check whether the package is installed or not on your system. In this case I’m going to check openssh package.

[email protected] [~]# yum list installed openssh
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos.hyve.com
 * epel: mirrors.coreix.net
 * extras: centos.hyve.com
 * rpmforge: www.mirrorservice.org
 * updates: mirror.sov.uk.goscomb.net
Installed Packages
openssh.x86_64                                                    5.3p1-104.el6_6.1                                                     @updates

11) yum provides / whatprovides function

This command searches which packages provide the requested dependency of file.

[email protected] [~]# yum provides /etc/passwd
or
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos.hyve.com
 * epel: mirrors.coreix.net
 * extras: centos.hyve.com
 * rpmforge: www.mirrorservice.org
 * updates: mirror.sov.uk.goscomb.net
setup-2.8.14-20.el6_4.1.noarch : A set of system configuration and setup files
Repo        : base
Matched from:
Filename    : /etc/passwd

setup-2.8.14-20.el6_4.1.noarch : A set of system configuration and setup files
Repo        : installed
Matched from:
Other       : Provides-match: /etc/passwd

12) Purpose of makecache

Makecache is used to download and make usable all the metadata for the currently enabled repository on your system.

[email protected] [~]# yum makecache

13) Print yum repositories

Use the below command to print the list of repositories available on your system.

# To print enabled repository #
[email protected] [~]# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos.hyve.com
 * epel: mirrors.coreix.net
 * extras: centos.hyve.com
 * rpmforge: www.mirrorservice.org
 * updates: mirror.sov.uk.goscomb.net
repo id                                        repo name                                                                              status
base                                           CentOS-6 - Base                                                                          6,456+62
epel                                           Extra Packages for Enterprise Linux 6 - x86_64                                         10,483+671
extras                                         CentOS-6 - Extras                                                                              36
isv_ownCloud_community                         Latest stable community release of ownCloud (CentOS_CentOS-6)                                 2+1
rpmforge                                       RHEL 6 - RPMforge.net - dag                                                              4,677+41
updates                                        CentOS-6 - Updates                                                                         496+34
repolist: 22,150

# To print Disabled repository #
[email protected] [~]# yum repositories disabled

# To print all repository #
[email protected] [~]# yum repolist all

14) Do full system update

Use the below command to keep your system up to date. It will install all the available updates.

[email protected] [~]# yum update

15) list available group packages

Use the below command to list available group of packages on your system. In these groups no of packages are bundled together with a single name. So you can install the group of packages with single shot instead of installing each and every software separately.

[email protected] [~]# yum grouplist

16) Install the group packages

To install group of packages use groupinstall instead of install with yum command. In this case i’m going to install “Development tools”. Its bundled with libtool, gcc, c++, automake, pkgconfig, autoconf, etc.,

[email protected] [~]# yum groupinstall 'Development tools'

16) update the group packages

Use the below command to update the group of packages to latest version.

[email protected] [~]# yum groupupdate 'Development tools'

17) Remove the group packages

Use the below command to update the group of packages to latest version.

[email protected] [~]# yum groupremove 'Development tools'
or
[email protected] [~]# yum grouperase 'Development tools'

18) Install a package from particular Repository

Use the below command to Install a package from particular Repository. In this case I’m going to install Htop package from rpmforge repository.

[email protected] [~]# yum --enablerepo=rpmforge install htop

19) Cleaning yum cache

Whenever you are installing packages yum creates a cache of metadata and packages. This cache can take up a lot space. The yum clean command allows you to clean up these files. All the files yum clean will act on are normally stored in /var/cache/yum.

# cleans up any cached packages #
[email protected] [~]# yum clean packages

# cleans up any cached xml metadata #
[email protected] [~]# yum clean metadata

# cleans up any cached db packages #
[email protected] [~]# yum clean dbcache

# Clean all cached files #
[email protected] [~]# yum clean all

20) checking Recently Added Packages into Repository

Use the below command to check Recently Added Packages into Repository.

[email protected] [~]# yum list recent

21) Print yum history

Use the below command to Print yum history.

[email protected] [~]# yum history

22) yum man page

Use the below command for More info about yum command.

[email protected] [~]# yum -help
or
[email protected] [~]# man yum
or
[email protected] [~]# yum --h

This my last article for 2014…Happy New year to all our readers..)

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...

Close
Please support the site
By clicking any of these buttons you help our site to get better