Showing posts with label rhel. Show all posts
Showing posts with label rhel. Show all posts

2011-06-14

A Reference on Yum, Yellowdog Updater, Modified

Recently, I had to mess with yum a lot. It is a powerful command line package management tool for RPM packages, and if you want to do automatic mass installations and updates, as in my case, GUI is not an option. I have collected the commands I have used among others, and created a reference.

All these commands have been tested on Scientific Linux 6.0 x86_64.
The version of yum I have used is 3.2.27.

# A reference to Yum, Yellowdog Updater, Modified
# http://caglartoklu.blogspot.com

# Yum is a command line package manager for
# RPM-compatible Linux operating systems.

Note that these commands requires root privileges.

# _____ Updates

# Check for availability package updates.
yum check-update

# Update all installed packages.
yum update

# Update a specific package.
yum update package_name
# Example:
yum update mc



# _____ Searching and finding about what to install

# List the depencies of a package.
yum deplist package_name
# Example:
yum deplist emacs

# Search a string in the metadata of packages.
# This metadata includes: name, summary,
# description, url.
yum search ri

# Let's say you want the command 'ri' but
# do not know which package is providing it. Type:
yum provides ri
# and you will see that 'ruby-ri-1.8.7.299....'
# package os providing it.

# Information about a package.
# Note that the package does not have to be
# installed on your system, it will display
# the information anyway.
yum info package_name
# Example:
yum info mc

# Install a package or packages.
yum install package_name
yum install package_name1 package_name2
# Example: yum install mc

# List the packages.
yum list all
yum list available
yum list updates
yum list installed
yum list extra
yum list obsoletes
yum list recent



# _____ Installing and removing packages

# Remove a package or packages from your system.
yum remove package_name
yum remove package_name1 package_name2
# erase command can also be used.
yum erase package_name
yum erase package_name1 package_name2

# Install a package or packages.
yum install package_name1 package_name2
# Example:
yum install mc emacs

# You can also install a package for a specific
# architecture like this:
yum install package_name.architecture
# See 'Specifying package names' in this document.
# Architecture can be x86_64 or i386.
# Example:
yum install mc.x86_64

# Install a local RPM.
yum localinstall package_name

# Update the distro using the RPMs saved locally.
# cd to the directory you saved your rpms, and type:
yum localupdate *.rpm



# _____ Downloading packages

# Download a package (current directory by default)
yumdownloader package_name
# If you do not have the yumdownloader,
# install yum-utils using:
yum install yum-utils



# _____ Groups

# See the list of groups installed:
yum grouplist
# This command will first list the installed groups,
# then the available ones.

# After seeing the list, see the information about.
# about a group. If the group name includes a space,
# enclose the group name with ' character.
yum groupinfo group_name
# Example:
yum groupinfo 'FTP server'

# Install packages of a group. Note that default
# and mandatory ones will be installed.
yum groupinstall group_name
# Example:
yum groupinstall 'FTP server'

# Update packages of a group.
yum groupupdate group_name
# Example:
yum groupupdate 'FTP server'

# Remove all packages of a group.
yum groupremove group_name
# Example:
yum groupremove 'FTP server'



# _____ Specifying package names

# A package can be referred to for install, update,
# list, remove etc with any of the following:
name
name.arch
name-ver
name-ver-rel
name-ver-rel.arch
name-epoch:ver-rel.arch
epoch:name-ver-rel.arch


# _____ Shell

# To start the interactive shell, type:
yum shell


# _____ References

http://www.linuxcommand.org/man_pages/yum8.html
http://yum.baseurl.org/
http://en.wikipedia.org/wiki/Yellowdog_Updater,_Modified 


If you do not see the code, you may be running a JavaScript blocker. Then you can directly jump to the source of the code on Pastebin: http://pastebin.com/dbCHYEh0

Enabling Caching Yum Downloads on Linux

I needed to copy the packages and updates performed on a Scientific Linux 6.0 x86_64 (call it A, connected to Internet) to another server(call it B). This second server has no Internet connection, and can not access to repositories but it is the main server in a project. So, I am keeping the server A as "mirror" of the server B. By this way, I can copy the updates as RPM files from server A to the unconnected server B.

Here is what I did to perform it using Yum:
First, make sure that the downloaded packages are cached in server A, that is, they are not deleted after the installation. To do that become root and type

vi /etc/yum.conf

And edit the line starting with keepcache, make sure that it is like this:

keepcache=1

Note your cachedir there.
It is defined as

cachedir=/var/cache/yum/$basearch/$releasever

It is expanded in my system as:

/var/cache/yum/x86_64/6.0/sl/packages

Now, whenever you use yum from command line or GUI, the downloaded packages can be found there and copied freely.