YUM guide for Linux RPM based distros
Running an IT Support company in Bristol we provide support for a lot of Linux servers & desktops mainly running CentOS or Fedora. We are often asked questions about how to install RPM’s, how to settle dependencies and how to keep desktops and servers up to date. The answer of course is YUM, the package manager of choice for RPM based Linux distributions. YUM is your friend when it comes to installing new software, keeping your system up to date or removing unwanted software.
I have compiled a guide to using YUM below, the instructions should be the same for any RPM based Linux distro such as CentOS, RHEL, Fedora etc.
How to update all RPM packages with YUM
How to update a single installed RPM package with YUM
yum update package-name
How to install RPM packages with YUM
yum install package-name
How to 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…
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.
Uninstall Packages using YUM
yum remove package-name
yum erase package-name
List information about about Packages with YUM
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.
yum list package-name
Yum – Find out what a package does
For example if you want to find out what the httpd package does.
yum provides httpd
Which should display something similar to the following:
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:
yum search bacula
Which would give me the following out put:
[root@centos1 ~]# 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.
How to 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.
[root@centos1 ~]# 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 : http://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
Over time these RPM files can take up a lot of space… To clear up yum enter:
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:
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:
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.
yum deplist package-name
How to use 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.
Show version of YUM you have installed
Install packages into a chroot with YUM
If you need to install packages into a chroot with YUM then use the following:
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:
yum --enablerepo=epel install rsnapshot
The above example would install rsnapshot from the epel repo if you had it installed but disabled.
Disable 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:
yum --disablerepo=epel install package-name
Any questions post a comment 🙂
Leave a Reply
You must be logged in to post a comment.