Académique Documents
Professionnel Documents
Culture Documents
Introduction
During the labs you might find that some commands are not found on your computer. Don't
panic, if you have not misspelled anything there, your system just misses the required
executable. However, today it is very simple to fix this issue, as all you have to do is to find
and install the software required. This is done in Linux world using package managers and
packets.
In CentOS and in many other Linux distribution, software comes into packages. One single
file contains all you need to perform the install on your computer. And thanks to package
management software, it is easy to find the required packages on the Internet, download them
and actually perform the install procedure.
If you ask people that worked with Linux for many years, they will tell you that things were
not always that easy. Years ago, system administrators didn't have package managers. They
had to download C/C++ sources, compile them and finally, install binaries on the system. But
that works after they already setup the development tools required for compilation.
Another major problem was caused by libraries. Remember from the first course, libraries are
collections of functionalities shared by different software components. It just doesn't make
sense to add the code for printing a string to the terminal in each executable, if it is possible to
load it dynamically from a shared file when each binary that needs it is called. But what if
such a library is missing from the system? Err, go back, first install the library and than try to
re-run your program. And this is an example of what we call dependencies.
The software itself is shipped already compiled and ready to be configured and used. But
what is the purpose of the specifications added inside the package. Well, the specifications or
requirements are here to solve the dependency problem. A software installed without having
all the pre-requisites installed is useless. Therefore, a package manager will install a package
only after all the dependencies are satisfied, otherwise it will try to download other packages
to fulfill those requirements.
What about the other scripts included? Well, a package file contains scripts required to
perform install, update or remove steps. Basically, the install script perform what an installer
should do. It copies the new files in configured folders, performs initial setup if necessary and
so on. The remove script actually removes files from the computer. However, some packages
won't remove all the files installed: a database server can keep the existing database, web
browsers can still save the preferences of the users, etc. The update script contains
instructions regarding what should be done if an older version of the package exists on the
system and the users decides to update it. Think that the database server should not erase the
existing data during an update process.
Modern Linux distros use package managers. A package manager is a program specialized in
searching, installing, removing and updating packages. In CentOS we use the yum package
manager, which is a command line tool written in python. It is also possible to perform those
tasks from the GUI application.
Apart from performing install/update/remove tasks, the package manager should make
package management more user friendly. For example, yum groups packages by
functionalities and it is possible to install a full group at once. In the previous print screen you
can see groups in the right panel.
Ok, so we can install packages with yum and the Add/Remove Software tool. But where do
those packages come from? The first source of packages is the DVD/CD medium used during
the install process. In fact, Anaconda, the CentOS installer, just unpacks packages during the
setup wizard.
However, most of the packages that you will install on a working server will come from
Internet. And we have to explain some terms before proceeding. First of all, the concept of
repository represents a set of packages, with associated metadata, including a list of mirrors.
This repository (the collection of packages) can be found on different servers from the
Internet, machines that contain the same collection of software...yes, the mirrors.
Packages can be found on the Web also and can be downloaded using a browser. For
example, you can use a dedicated search engine like rpm.pbone.net
Once you found your package, download and install it using rpm tool.
On of the basic things that you can do with rpm is to query the database and test if a package
is installed. To test this use:
rpm -q <package_name>
To list all packages listed in the system, use rpm -qa. If you pass the output to grep, you can
filter the output. Examples are provided bellow.
Now that we have a package downloaded from pbone, we can install it with rpm. To install a
package use;
rpm -i -v -h <package_file>
To explain the switches used: -i specifies to perform an install, while -v and -h will make the
output more verbose.
If you just want to test if the install would be performed successfully, without actually doing
it, add --test flag.
To update a package, considering that an existing version is already installed, replace -i with -
U:
rpm -U -v -h <package_file>
rpm -e -v <package_name>
Note that package_file refers to the entire path (relative or absolute) to an rpm package, while
package_name must contain only the package name, without version, release, architecture,
etc. Omitting those details when referring to a package is called globbing.
Note that performing an update if there is no existing version of the package installed
transforms the process into an install. However, note that if there is an older version installed,
that one would be erased. This is why you should take care when installing kernel packages.
Always install new kernels (with -i) and don't update, because that would erase the existing
one and next time you will boot with a brand new untested kernel, without any fall-back
option.
The rpm command line tool can be used to query specific information either from the rpm
database about the installed packages or from a stand-alone rpm file. First let's focus on
querying the rpm database.
rpm -q -i <package_name>
rpm -q -l <package_name>
To list the requirements of a package:
rpm -q -R <package_name>
rpm -q -l -c <package_name>
Those queries will ask the rpm database. However, if you have a local rpm file, you can query
the file itself, just add the -p option and replace the <package_name> with the path to the rpm
file, thus resulting:
rpm -q -i -p <package_file>
rpm -q -l -p <package_file>
rpm -q -R -p <package_file>
rpm -q -l -c -p <package_file>
rpm -V <package_name>
The files modified will be listed bellow, along with flags specific flags for each change.
5 - md5 checksum
S - file size
T - file mofication time
U - user
G - group
M - mode
Yum - Package manager, groups, operations,
downloadonly
We discussed about rpm, the package level management tool. However, installing all
packages by hand with rpm would take a lot for a system administrator. It is not only about
performing the install with a command like rpm -ivh <package_file>, but it is about
solving dependencies. Whenever you try to install a package that has unresolved
dependencies, rpm will just shout a message and stop.
This is a reason why using rpm alone is not efficient. We need a software capable to manage
software packages from a higher level perspective. We need YUM.
Yum or the Yellowdog Updater Modified is the default package manager for CentOS. It can
be used for performing software installations and it will make sure that once you try to install
a program, all dependencies required will be installed also. Yum can also be used for
removing and updating packages, as well as for searching. Check out the different approach
of Yum while installing elinks with yum install elinks command:
Let's list some simple commands of yum.
It is also possible to perform a full system upgrade with yum update. yum check-update
will check for updates ans list all upgradeable packages.
To get a list of installed packages is possible to use yum list installed.
Also, note yum info <package> which provides information about a package and yum
deplist which lists the dependencies of a package.
For example, to see the list of defined groups use yum grouplist
To get details about a specific group and see what packages are actually included, execute yum
groupinfo <group>:
Nice, so yum can install packages or entire group of packages. But where do those packages
come from? Yum uses repositories. Remember? Repositories were collections of software.
Repositories can be stored on local file system, on a server reachable through Internet, etc. .
Most of the time, you will install software using your Internet connection from mirrors. Yum
defines repositories through configuration files stored in /etc/yum.repos.d/ folder:
Regarding the GPG-related settings: note that another role of yum is to check the authenticity
and the integrity of downloaded packages according to the keys installed.
With such vast collections of packages, it would be hard to find the right package when you
need it. But yum provides some interesting search options to ease that task. The first option is
to search for a word in the package name and the description associated
Note that this will search in an absolute path list. If you don't know the absolute path (and this
is likely to happen), use */<filename> For example, to search for the package providing the
snmptrap binary, execute yum whatprovides */snmptrap
First of all, you will need to visit the site of the project and download a special rpm, called
release rpm. This package contains the configuration file that will be installed in
/etc/yum.repos.d folder and the key used to sign the packages from EPEL repo.
To get this package, visit http://fedoraproject.org/wiki/EPEL and look for The newest
version of 'epel-release' for EL6 link. Download the package to your machine using the wget
command line tool and than install it using rpm. Finally, chek that everything is ok with the
yum repolist command.
And this is it. Now you can install packages from EPEL repository.
By default, yum is not capable to do this. However, you after you will install the yum-
downloadonly plugin it will become possible. To install the plugin, use yum.
Finally, to use the download-only functionality, add the --downloadonly flag to the normal
install command.
The output looks similar to a normal installation, but it will stop before unpacking the rpms.
You can find the packages in folders under /var/cache/yum, but it won't be an easy task. You
should use the --downloaddir option to specify a destination.
Other distributions
Few words about other distributions. In Red Hat and other RHEL clones you will find yum
and rpm tools for installing rpm packages, so nothing new. However, other distributions have
a similar architecture but use different tools and packages.
Debian-based distributions use .deb packages. The package level tool is dpkg which works
similar to rpm. There is also a package manager called aptitude which performs similar
tasks like yum.
Examples of other package managers are Zypper, Yast, DNF (successor of yum), pacman, etc.
1. get application sources (download archives from web, etc) & read the README file
2. make sure you have "Development Tools" group installed or install it
3. change directory to source folder
4. run ./configure script. This will detect available tools and libraries installed on the
local system and will adjust makefiles
5. run make to compile software
6. run make install to install the newly compiled software