-->

Installing Software On Linux - Working with Red Hat packages

The Red Hat–Based Systems

Like the Debian-based distributions, the Red Hat–based systems have several different front-end tools that are available. These are the common ones:

  • yum: Used in Red Hat and Fedora 
  • urpm: Used in Mandriva
  • zypper: Used in openSUSE

These front-ends are all based on the rpm command line tool. The following section discusses how to manage software packages using these various rpm-based tools. The focus is on yum, but information is also included for zypper and urpm.

Installing Software On Linux - Working with Red Hat packages
Installing Software On Linux - Working with Red Hat packages

Listing installed packages

To find out what is currently installed on your system, at the shell prompt, type the following command:
yum list installed
The information will probably whiz by you on the display screen, so it’s best to redirect the installed software listing into a file. You can then use the more or less command (or a GUI editor) to look at the list in a controlled manner.
yum list installed > installed_software
To list out the installed packages on your openSUSE or Mandriva distribution, see the commands in Table. Unfortunately, the urpm tool used in Mandriva cannot produce a currently installed software listing. Thus, you need to revert to the underlying rpm tool.

How to List Installed Software with zypper and urpm
How to List Installed Software with zypper and urpm

To find out detailed information for a particular software package, yum really shines. It gives you a very verbose description of the package, and with another simple command, you can see whether the package is installed:

  1. # yum list xterm
  2. Loaded plugins: langpacks, presto, refresh-packagekit
  3. Adding en_US to language list
  4. Available Packages
  5. xterm.i686 253-1.el6
  6. ##
  7. yum list installed xterm
  8. Loaded plugins: refresh-packagekit
  9. Error: No matching Packages to list
  10. #


The commands to list detailed software package information using urpm and zypper are in Table. You can acquire an even more detailed set of package information from the repository, using the info option on the zypper command.

How to See Various Package Details with zypper and urpm
How to See Various Package Details with zypper and urpm

Finally, if you need to find out what software package provides a particular file on your filesystem, the versatile yum can do that, too! Just enter the command:
yum provides file_name
Here’s an example of trying to find what software provided the configuration file /etc/yum.conf:

  1. #
  2. # yum provides /etc/yum.conf
  3. Loaded plugins: fastestmirror, refresh-packagekit, security
  4. Determining fastest mirrors
  5. * base: mirror.web-ster.com
  6. * extras: centos.chi.host-engine.com
  7. * updates: mirror.umd.edu
  8. yum-3.2.29-40.el6.centos.noarch : RPM package installer/updater/manager
  9. Repo        : base
  10. Matched from:
  11. Filename    : /etc/yum.conf
  12. yum-3.2.29-43.el6.centos.noarch : RPM package installer/updater/manager
  13. Repo        : updates
  14. Matched from:
  15. Filename    : /etc/yum.conf
  16. yum-3.2.29-40.el6.centos.noarch : RPM package installer/updater/manager
  17. Repo        : installed
  18. Matched from:
  19. Other       : Provides-match: /etc/yum.conf
  20. #
  21. #


answer is: the yum software package provides this file!

Installing software with yum

Installation of a software package using yum is incredibly easy. The following is the basic command for installing a software package, all its needed libraries, and package dependencies from a repository:
yum install package_name
Here’s an example of installing the xterm package:

  1. $ su -
  2. Password:
  3. # yum install xterm
  4. Loaded plugins: fastestmirror, refresh-packagekit, security
  5. Determining fastest mirrors
  6. * base: mirrors.bluehost.com
  7. * extras: mirror.5ninesolutions.com
  8. * updates: mirror.san.fastserv.com
  9. Setting up Install Process
  10. Resolving Dependencies
  11. —> Running transaction check
  12. –> Package xterm.i686 0:253-1.el6 will be installed
  13. —> Finished Dependency Resolution
  14. Dependencies Resolved
  15. […]
  16. Installed:
  17. xterm.i686 0:253-1.el6
  18. Complete!
  19. #


Note
Before the yum command in the preceding listing, the su - command is used. This command allows you to switch to the root user. On this Linux system, the # denotes you are logged in as root. You should only switch to root user temporarily in order to run administrative tasks, such as installing and updating software. The sudo command is another option as well.

You can also manually download an rpm installation file and install it using yum. This is called a local installation. This is the basic command:
yum localinstall package_name.rpm
You can begin to see that one of yum‘s strengths is that it uses very logical and user friendly commands.

The Table below will shows how to perform a package install with urpm and zypper. You should note
that if you are not logged in as root, you get a “command not found” error message using urpm.

How to Install Software with zypper and urpm
How to Install Software with zypper and urpm

Updating software with yum

In most Linux distributions, when you’re working away in the GUI, you get those nice little notification icons telling you that an update is needed. Here at the command line, it takes a little more work.

To see the list of all the available updates for your installed packages, type the following command:
yum list updates
It’s always nice to get no response to this command because it means you have nothing to update! However, if you do discover a particular software package needs updating, type the following command:
yum update package_name
If you’d like to update all the packages listed in the update list, just enter the following command:
yum update
Commands for updating software packages on Mandriva and openSUSE are listed in Table below. When urpm is used, the repository database is automatically refreshed as well as software packages updated.

How to Update Software with zypper and urpm
How to Update Software with zypper and urpm

Uninstalling software with yum

The yum tool also provides an easy way to uninstall software you no longer want on your system. As with aptitude, you need to choose whether to keep the software package’s data and configuration files.

To just remove the software package and keep any configuration and data files, use the following command:
yum remove package_name
To uninstall the software and all its files, use the erase option:
yum erase package_name
It is equally easy to remove software using urpm and zypper in Table below. Both of these tools perform a function similar to yum‘s erase option.

How to Uninstall Software with zypper and urpm
How to Uninstall Software with zypper and urpm

Although life is considerably easier with PMS packages, it’s not always problem-free. Occasionally, things do go wrong. Fortunately, there’s help.

Dealing with broken dependencies

Sometimes, as multiple software packages get loaded, a software dependency for one package can get overwritten by the installation of another package. This is called a broken dependency.

If this should happen on your system, first try the following command:
yum clean all
Then try to use the update option in the yum command. Sometimes, just cleaning up any misplaced files can help.

If that doesn’t solve the problem, try the following command:
yum deplist package_name
This command displays all the package’s library dependencies and what software package provides them. After you know the libraries required for a package, you can then install them. Here’s an example of determining the dependencies for the xterm package:

  1. # yum deplist xterm
  2. Loaded plugins: fastestmirror, refresh-packagekit, security
  3. Loading mirror speeds from cached hostfile
  4. * base: mirrors.bluehost.com
  5. * extras: mirror.5ninesolutions.com
  6. * updates: mirror.san.fastserv.com
  7. Finding dependencies:
  8. package: xterm.i686 253-1.el6
  9. dependency: libncurses.so.5
  10. provider: ncurses-libs.i686 5.7-3.20090208.el6
  11. dependency: libfontconfig.so.1
  12. provider: fontconfig.i686 2.8.0-3.el6
  13. dependency: libXft.so.2
  14. provider: libXft.i686 2.3.1-2.el6
  15. dependency: libXt.so.6
  16. provider: libXt.i686 1.1.3-1.el6
  17. dependency: libX11.so.6
  18. provider: libX11.i686 1.5.0-4.el6
  19. dependency: rtld(GNU_HASH)
  20. provider: glibc.i686 2.12-1.132.el6
  21. provider: glibc.i686 2.12-1.132.el6_5.1
  22. provider: glibc.i686 2.12-1.132.el6_5.2
  23. dependency: libICE.so.6
  24. provider: libICE.i686 1.0.6-1.el6
  25. dependency: libXaw.so.7
  26. provider: libXaw.i686 1.0.11-2.el6
  27. dependency: libtinfo.so.5
  28. provider: ncurses-libs.i686 5.7-3.20090208.el6
  29. dependency: libutempter.so.0
  30. provider: libutempter.i686 1.1.5-4.1.el6
  31. dependency: /bin/sh
  32. provider: bash.i686 4.1.2-15.el6_4
  33. dependency: libc.so.6(GLIBC_2.4)
  34. provider: glibc.i686 2.12-1.132.el6
  35. provider: glibc.i686 2.12-1.132.el6_5.1
  36. provider: glibc.i686 2.12-1.132.el6_5.2
  37. dependency: libXmu.so.6
  38. provider: libXmu.i686 1.1.1-2.el6
  39. #


If that doesn’t solve your problem, you have one last tool:
yum update —skip-broken
The —skip-broken option allows you to just ignore the package with the broken dependency and update the other software packages. This may not help the broken package, but at least you can update the remaining packages on the system!

yum repositories

Just like the aptitude systems, yum has its software repositories set up at installation. For most purposes, these pre-installed repositories work just fine for your needs. But if and when the time comes that you need to install software from a different repository, here are some things you need to know.

Tip
A wise system administrator sticks with approved repositories. An approved repository is one that is sanctioned by the distribution’s official site. If you start adding unapproved repositories, you lose the guarantee of stability. And you will be heading into broken dependencies territory
To see what repositories you are currently pulling software from, type the following command:
yum repolist
If you don’t find a repository you need software from, you need to do a little configuration file editing. The yum repository definition files are located in /etc/yum.repos.d. You need to add the proper URL and gain access to any necessary encryption keys.

Good repository sites such as rpmfusion.org lay out all the steps necessary to use them. Sometimes, these repository sites offer an rpm file that you can download and install using the yum localinstall command. The installation of the rpm file does all the repository setup work for you. Now that’s convenient!

urpm calls its repositories media. The commands for looking at urpm media and zypper‘s repositories are in Table. Notice with both of these front-end tools that you do not edit a configuration file. Instead, to add media or a repository, you just type the command.

zypper and urpm Repositories
zypper and urpm Repositories

Both Debian–based and Red Hat–based systems use Package Management Systems to ease the process of managing software. Now we are going to step out of the world of Package Management Systems and look at something a little more difficult: installing directly from source code.

Installing from Source Code

Chapter 4 discussed tarball packages — how to create them using the tar command line command and how to unpack them. Before the fancy rpm and dpkg tools, administrators had to know how to unpack and install software from tarballs.

If you work in the open source software environment much, there’s a good chance you will still find software packed up as a tarball. This section walks you through the process of unpacking and installing a tarball software package.

For this example, the software package sysstat is used. The sysstat utility is a very nice software package that provides a variety of system monitoring tools.

First, you need to download the sysstat tarball to your Linux system. You can often find the sysstat package available on different Linux sites, but it’s usually best to go straight to the source of the program. In this case, it’s the website http://sebastien.godard.pagesperso-orange.fr/.

If you click the Download link, you go to the page that contains the files for downloading.

The current version at the time of this writing is 11.1.1, and the distribution file name is
sysstat-11.1.1.tar.gz.
Click the link to download the file to your Linux system. After you have downloaded the file, you can unpack it.

To unpack a software tarball, use the standard tar command:

  1. #
  2. # tar -zxvf sysstat-11.1.1.tar.gz
  3. sysstat-11.1.1/
  4. sysstat-11.1.1/cifsiostat.c
  5. sysstat-11.1.1/FAQ
  6. sysstat-11.1.1/ioconf.h
  7. sysstat-11.1.1/rd_stats.h
  8. sysstat-11.1.1/COPYING
  9. sysstat-11.1.1/common.h
  10. sysstat-11.1.1/sysconfig.in
  11. sysstat-11.1.1/mpstat.h
  12. sysstat-11.1.1/rndr_stats.h
  13. […]
  14. sysstat-11.1.1/activity.c
  15. sysstat-11.1.1/sar.c
  16. sysstat-11.1.1/iostat.c
  17. sysstat-11.1.1/rd_sensors.c
  18. sysstat-11.1.1/prealloc.in
  19. sysstat-11.1.1/sa2.in
  20. #
  21. #

Now that the tarball is unpacked and the files have neatly put themselves into a directory called sysstat-11.1.1, you can dive down into that directory and continue.

First, use the cd command to get into the new directory and list the contents of the directory:
$ cd sysstat-11.1.1


In the listing of the directory, you should typically see a README or AAAREADME file. It is very important to read this file. The actual instructions you need to finish the software’s installation are in this file.

Following the advice contained in the README file, the next step is to configure sysstat for your system. This checks your Linux system to ensure it has the proper library dependencies, in addition to the proper compiler to compile the source code:

  1. # ./configure
  2. Check programs:
  3. . checking for gcc… gcc
  4. checking whether the C compiler works… yes
  5. checking for C compiler default output file name… a.out
  6. […]
  7. checking for ANSI C header files… (cached) yes
  8. checking for dirent.h that defines DIR… yes
  9. checking for library containing opendir… none required
  10. checking ctype.h usability… yes
  11. checking ctype.h presence… yes
  12. checking for ctype.h… yes
  13. checking errno.h usability… yes
  14. checking errno.h presence… yes
  15. checking for errno.h… yes
  16. […]
  17. Check library functions:
  18. . checking for strchr… yes
  19. checking for strcspn… yes
  20. checking for strspn… yes
  21. checking for strstr… yes
  22. checking for sensors support… yes
  23. checking for sensors_get_detected_chips in -lsensors… no
  24. checking for sensors lib… no
  25. . Check system services:
  26. . checking for special C
  27. compiler options needed for large files… no
  28. checking for _FILE_OFFSET_BITS value needed for large files… 64
  29. . Check configuration:
  30. […]
  31. Now create files:
  32. […]
  33. config.status: creating Makefile
  34. Sysstat version: 11.1.1
  35. Installation prefix: /usr/local
  36. rc directory: /etc/rc.d
  37. Init directory: /etc/rc.d/init.d
  38. Systemd unit dir:
  39. Configuration directory: /etc/sysconfig
  40. Man pages directory: ${datarootdir}/man
  41. Compiler: gcc
  42. Compiler flags: -g -O2
  43. #


If anything does go wrong, the configure step displays an error message explaining what’s missing. If you don’t have the GNU C compiler installed in your Linux distribution, you get a single error message, but for all other issues you should see multiple messages indicating what’s installed and what isn’t.

The next stage is to build the various binary files using the make command. The make command compiles the source code and then the linker to create the final executable files for the package. As with the configure command, the make command produces lots of output as it goes through the steps of compiling and linking all the source code files:

  1. # make
  2. –gcc -o sadc.o -c -g -O2 -Wall -Wstrict-prototypes -pipe -O2
  3. -DSA_DIR="/var/log/sa" -DSADC_PATH="/usr/local/lib/sa/sadc"
  4. -DUSE_NLS -DPACKAGE="sysstat"
  5. -DLOCALEDIR="/usr/local/share/locale" sadc.c
  6. gcc -o act_sadc.o -c -g -O2 -Wall -Wstrict-prototypes -pipe -O2
  7. -DSOURCE_SADC -DSA_DIR="/var/log/sa"
  8. -DSADC_PATH="/usr/local/lib/sa/sadc"
  9. -DUSE_NLS -DPACKAGE="sysstat"
  10. -DLOCALEDIR="/usr/local/share/locale" activity.c
  11. […]
  12. #

When make is finished, you have the actual sysstat software program available in the directory! 

However, it’s somewhat inconvenient to have to run it from that directory. Instead, you’ll want to install it in a common location on your Linux system. To do that, you need to log in as the root user account (or use the sudo command if your Linux distribution prefers) and then use the install option of the make command:

  1. # make install
  2. mkdir -p /usr/local/share/man/man1
  3. mkdir -p /usr/local/share/man/man5
  4. mkdir -p /usr/local/share/man/man8
  5. rm -f /usr/local/share/man/man8/sa1.8*
  6. install -m 644 -g man man/sa1.8 /usr/local/share/man/man8
  7. rm -f /usr/local/share/man/man8/sa2.8*
  8. install -m 644 -g man man/sa2.8 /usr/local/share/man/man8
  9. rm -f /usr/local/share/man/man8/sadc.8*
  10. […]
  11. install -m 644 -g man man/sadc.8 /usr/local/share/man/man8
  12. install -m 644 FAQ /usr/local/share/doc/sysstat-11.1.1
  13. install -m 644 *.lsm /usr/local/share/doc/sysstat-11.1.1
  14. #


Now the sysstat package is installed on the system! Although it’s not quite as easy as installing a software package via a PMS, installing software using tarballs is not that difficult.

This chapter discussed how to work with a Package Management Systems (PMS) to install, update, or remove software from the command line. Although most of the Linux distributions use fancy GUI tools for software package management, you can also perform package management from the command line.

The Debian-based Linux distributions use the dpkg utility to interface with the PMS from the command line. A front-end to the dpkg utility is aptitude. It provides simple command line options for working with software packages in the dpkg format.

The Red Hat–based Linux distributions are based on the rpm utility but use different frontend tools at the command line. Red Hat and Fedora use yum for installing and managing software packages. The openSUSE distribution uses zypper for managing software, while the Mandriva distribution uses urpm.

The chapter closed with a discussion on how to install software packages that are only distributed in source code tarballs. The tar command allows you to unpack the source code files from the tarball, and configure and make allow you to build the final executable program from the source code.

The next chapter looks at the different editors available in Linux distributions. As you get ready to start working on shell scripts, it will come in handy to know what editors are available to use!

0 Response to "Installing Software On Linux - Working with Red Hat packages"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel