Yum Commands

tested on Centos 6

Yellow dog Updater, Modified (Yum) is the default package manager used in all versions of CentOS. It is used to install and update packages from CentOS and third party repositories.


using a proxy server

To allow yum operations to use a proxy server, specify the proxy server details in file /etc/yum.conf

# vi /etc/yum.conf

## add line identifying proxy server, and proxy server port number
proxy=http://999.999.999.999:9999
proxy=http://mydomain.com:9999
example:
proxy=http://172.16.50.3:3128

Clean

Clean all eliminate any unneeded cached data, header files, temporary files, cached data. Sometime cleaning will eliminate strange error messages.

# yum clean all

Checking things

List enabled repositories.

# yum repolist
Loaded plugins: fastestmirror, security
...
atomic                                                   | 3.4 kB     00:00
base                                                     | 3.7 kB     00:00
extras                                                   | 3.4 kB     00:00
updates                                                  | 3.4 kB     00:00
repo id   repo name                                                       status
atomic    CentOS / Red Hat Enterprise Linux 6 - atomicrocketturtle.com    1,614
base      CentOS-6 - Base                                                 6,518
extras    CentOS-6 - Extras                                                  37
updates   CentOS-6 - Updates                                                804
repolist: 8,973

List all packages in all the repositories and all the packages installed on your system.

# yum list 

Determine whether any updates are available for your installed packages. yum returns a list of all package updates from all repositories if any are available.

# yum check-update

Get information about a package

# yum info packagename

Find a package containg a string in packge name or package summary

# yum search string

Find which package a command comes from

# yum provides packagename

To list all the installed packages on a system

# yum list installed 

Repoquery is a program for querying information from YUM repositories. Indicates where package is available, but not necessarily where it was installed from (if installed)

#repoquery -i mysql

Name        : mysql
Version     : 5.5.42
Release     : 28.el6.art
Architecture: i686
Size        : 29712001
Packager    : None
Group       : Applications/Databases
URL         : http://www.mysql.com
Repository  : atomic
Summary     : MySQL client programs and shared libraries
Source      : mysql-5.5.42-28.el6.art.src.rpm
Description :
MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. The base package
contains the standard MySQL client programs and generic MySQL files.
# repoquery -i mariadb

Name        : mariadb
Version     : 5.5.37
Release     : 16.el6.art
Architecture: x86_64
Size        : 50491204
Packager    : None
Group       : Applications/Databases
URL         : http://mariadb.org
Repository  : atomic
Summary     : A community developed branch of MySQL
Source      : mariadb-5.5.37-16.el6.art.src.rpm
Description :
MariaDB is a community developed branch of MySQL.
MariaDB is a multi-user, multi-threaded SQL database server.
It is a client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. The base package
contains the standard MariaDB/MySQL client programs and generic MySQL files.

Install/Remove/Update

Install/Remove specific package. Yum will automatically find and install all required dependencies for an install

# yum install packagename
# yum remove packagename
examples:
# yum install httpd
# yum install php

Update specific package.

# yum update packagename

Update all packages. Use this one carefully as it can erase data and customized configurations.

# yum update

see change history

# yum history
# yum history info

Security issues only

Concerned about security updates? First install special security plugin

yum install yum-plugin-security

then check for security updates

yum --security check-update

and upgrade all packages with security info to latest available package

yum --security update

Fix a stuck YUM record lock

# ps -ef | grep yum
root     16518 16499  0 14:52 pts/0    00:00:00 /usr/bin/python /usr/bin/yum list
root     16999 16555  0 15:00 pts/1    00:00:00 grep yum
# kill -9 16518
# yum update
make sure you kill correct PID!
wget -q -O - http://www.atomicorp.com/installers/atomic | sh