LinuxMoz

Linux Stuff && Coffee

Linux YUM Tutorial

| Comments

Ultimate Linux YUM tutorial, YUM is used on a number of Linux distributions such as Redhat RHEL, CentOS & Fedora. YUM uses repositories of RPM packages to download and install new software for your server, Linux Admin’s must learn YUM so they have an understanding of adding / removing packages on Linux systems and maintain up to date secure Linux servers.

The instructions for YUM should be the same for each Linux distro CentOS, RHEL or Fedora.

How to update all RPM packages with YUM

1
yum update

Update a single installed RPM package with YUM

1
yum update package-name

Install RPM packages with YUM

1
yum install package-name

Exclude a package from being updated with YUM

Say for example you want to update your system but you do not want the kernel to be updated…

1
yum --exclude=package kernel* update

How to check what packages need updating using YUM

This command checks all packages on Fedora, CentOS or RHEL to see if they need updating.

1
check-update

Uninstall Packages using YUM

1
yum remove package-name

Or…

1
yum erase package-name

List information about about Packages with YUM

The next step in our Linux yum tutorial is to find out more information about packages with use “yum list” it is best used with a package name, otherwise it will list info about all the packages in the YUM repos you have installed ;)

1
yum list package-name

Yum – Find out what a package does

For example if you want to find out what the httpd package does…

1
yum provides httpd

Which should display something similar to the following:

1
httpd-2.2.15-5.el6.centos.x86_64 : Apache HTTP Server

Search for a package with YUM

If you don’t know the name of the package search for it, this will search through the RPM’s info looking for the string you have provided. Say for example I want to find the package name for Bacula but I don’t know the name of it, I would enter the following:

1
yum search bacula

Which would give me the following out put:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@skywalker ~]# yum search bacula
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.netrino.co.uk
 * extras: mirror.netrino.co.uk
 * updates: mirror.netrino.co.uk
================================================= Matched: bacula =================================================
bacula-client.x86_64 : Bacula backup client
bacula-common.x86_64 : Common Bacula utilities
bacula-console.x86_64 : Bacula management console
bacula-console-bat.x86_64 : Bacula bat console
bacula-director-common.x86_64 : Common Bacula Director files
bacula-director-mysql.x86_64 : Bacula Director with MySQL database support
bacula-director-postgresql.x86_64 : Bacula Director with PostgresSQL database support
bacula-director-sqlite.x86_64 : Bacula Director with sqlite database support
bacula-docs.x86_64 : Bacula documentation
bacula-storage-common.x86_64 : Common Bacula storage daemon files
bacula-storage-mysql.x86_64 : MySQL Bacula storage daemon files
bacula-storage-postgresql.x86_64 : Common Bacula storage daemon files
bacula-storage-sqlite.x86_64 : SQLite Bacula storage daemon files
bacula-traymonitor.x86_64 : Bacula monitor for the Gnome and KDE system tray

Note if you search for something like apache, then you are going to get a huge list of packages so you might want to use the less or more command to allow easy scrolling of the output.

List yum Package info for a package

This is my favorite way of listing package info with yum, personally I do not use list I always use info, below is an example of the yum info command with httpd.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root@skywalker ~]# yum info httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.netrino.co.uk
 * extras: mirror.netrino.co.uk
 * updates: mirror.netrino.co.uk
Available Packages
Name       : httpd
Arch       : x86_64
Version    : 2.2.15
Release    : 5.el6.centos
Size       : 811 k
Repo       : base
Summary    : Apache HTTP Server
URL        : https://httpd.apache.org/
License    : ASL 2.0
Description: The Apache HTTP Server is a powerful, efficient, and extensible
           : web server.

How to clean up the yum cache and downloaded packages

Everytime you install packages with yum it downloads an RPM and installs it, over time these RPM files can take up a lot of space… To clear up yum enter:

1
yum clean all

How to use YUM to install local RPM files

Say for example you need to build your own RPM and install it locally you can use YUM to resolve dependancies this package might have from it’s repositories by using the following:

1
yum localinstall package-name.rpm

Use YUM to update a local RPM package

If you want to update a local rpm package using YUM enter the following:

1
yum localupdate update-package.rpm

Find out what dependancies an RPM package has

How to find out what deps a package has using yum, might be handy if you need to do a source install for something (shame on you!). deplist will show you what the package depends on and what packages provide them.

1
yum deplist package-name

Linux YUM Priorities

If you have a bunch of different repos installed on your system like the EPEL repo and you want to make sure when you install a package or update your system the packages come from the base system first if they don’t exist there then use a 3rd party repo. I would recommend you go follow our guide on How to use YUM priorities and check this guide out if you need instructions on how to install the EPEL repo.

Find out what version of YUM you have installed

1
yum -v

Install packages into a chroot with YUM

If you need to install packages into a chroot with YUM then use the following:

1
yum --installroot=/path/to/chroot/

Enable a disabled YUM repository on the command line

If you have a repo installed and you need to enable that repo to install a package, you can enter:

1
yum --enablerepo=epel install rsnapshot

The above example would install rsnapshot from the epel repo if you had it installed but disabled.

Disabled a YUM repository on the command line

If you have a repo installed and you need to disable that repo to prevent yum from installing a package form it, you can enter:

1
yum --disablerepo=epel install package-name

YUM Groups

A yum group is a collection of RPM packages for a specific purpose such as “Development Tools”. This guide shows you how to use yum groupinstall to list available yum groups and install / update / remove yum groups.

yum groupinstall (install a yum group)

1
yum groupinstall 'Development Tools'

yum groupremove (remove a yum group)

1
yum groupremove 'Development Tools'

yum groupupdate (update a yum group)

1
yum groupupdate 'Development Tools'

yum groupinfo (list packages in a yum group)

1
yum groupinfo 'Development Tools'

List YUM groups

1
yum grouplist | more

YUM List installed packages

How to YUM list installed packages on Linux, this should work on all Linux YUM distro’s such as CentOS, Fedora, RHEL etc.

To list all installed packages via YUM it’s as simple as entering:

1
yum list installed

This will display installed packages similar to the output below (the screen shot is a list of installed packages on a CentOS 6 server):

YUM list installed packages

The output from yum list installed is often rather large so you might want to pipe it through more:

1
yum list installed | more

I hope you have found this Linux YUM tutorial useful and if you can think of any other handy tips drop me a comment! And don’t forget to follow us on Twitter.

Comments