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 |
Listing installed packages
To find out what is currently installed on your system, at the shell prompt, type the following command:yum list installedThe 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_softwareTo 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 |
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:
- # yum list xterm
- Loaded plugins: langpacks, presto, refresh-packagekit
- Adding en_US to language list
- Available Packages
- xterm.i686 253-1.el6
- ##
- yum list installed xterm
- Loaded plugins: refresh-packagekit
- Error: No matching Packages to list
- #
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 |
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:
- #
- # yum provides /etc/yum.conf
- Loaded plugins: fastestmirror, refresh-packagekit, security
- Determining fastest mirrors
- * base: mirror.web-ster.com
- * extras: centos.chi.host-engine.com
- * updates: mirror.umd.edu
- yum-3.2.29-40.el6.centos.noarch : RPM package installer/updater/manager
- Repo : base
- Matched from:
- Filename : /etc/yum.conf
- yum-3.2.29-43.el6.centos.noarch : RPM package installer/updater/manager
- Repo : updates
- Matched from:
- Filename : /etc/yum.conf
- yum-3.2.29-40.el6.centos.noarch : RPM package installer/updater/manager
- Repo : installed
- Matched from:
- Other : Provides-match: /etc/yum.conf
- #
- #
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:
- $ su -
- Password:
- # yum install xterm
- Loaded plugins: fastestmirror, refresh-packagekit, security
- Determining fastest mirrors
- * base: mirrors.bluehost.com
- * extras: mirror.5ninesolutions.com
- * updates: mirror.san.fastserv.com
- Setting up Install Process
- Resolving Dependencies
- —> Running transaction check
- –> Package xterm.i686 0:253-1.el6 will be installed
- —> Finished Dependency Resolution
- Dependencies Resolved
- […]
- Installed:
- xterm.i686 0:253-1.el6
- Complete!
- #
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 |
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 |
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 |
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:
- # yum deplist xterm
- Loaded plugins: fastestmirror, refresh-packagekit, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.bluehost.com
- * extras: mirror.5ninesolutions.com
- * updates: mirror.san.fastserv.com
- Finding dependencies:
- package: xterm.i686 253-1.el6
- dependency: libncurses.so.5
- provider: ncurses-libs.i686 5.7-3.20090208.el6
- dependency: libfontconfig.so.1
- provider: fontconfig.i686 2.8.0-3.el6
- dependency: libXft.so.2
- provider: libXft.i686 2.3.1-2.el6
- dependency: libXt.so.6
- provider: libXt.i686 1.1.3-1.el6
- dependency: libX11.so.6
- provider: libX11.i686 1.5.0-4.el6
- dependency: rtld(GNU_HASH)
- provider: glibc.i686 2.12-1.132.el6
- provider: glibc.i686 2.12-1.132.el6_5.1
- provider: glibc.i686 2.12-1.132.el6_5.2
- dependency: libICE.so.6
- provider: libICE.i686 1.0.6-1.el6
- dependency: libXaw.so.7
- provider: libXaw.i686 1.0.11-2.el6
- dependency: libtinfo.so.5
- provider: ncurses-libs.i686 5.7-3.20090208.el6
- dependency: libutempter.so.0
- provider: libutempter.i686 1.1.5-4.1.el6
- dependency: /bin/sh
- provider: bash.i686 4.1.2-15.el6_4
- dependency: libc.so.6(GLIBC_2.4)
- provider: glibc.i686 2.12-1.132.el6
- provider: glibc.i686 2.12-1.132.el6_5.1
- provider: glibc.i686 2.12-1.132.el6_5.2
- dependency: libXmu.so.6
- provider: libXmu.i686 1.1.1-2.el6
- #
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 |
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:
- #
- # tar -zxvf sysstat-11.1.1.tar.gz
- sysstat-11.1.1/
- sysstat-11.1.1/cifsiostat.c
- sysstat-11.1.1/FAQ
- sysstat-11.1.1/ioconf.h
- sysstat-11.1.1/rd_stats.h
- sysstat-11.1.1/COPYING
- sysstat-11.1.1/common.h
- sysstat-11.1.1/sysconfig.in
- sysstat-11.1.1/mpstat.h
- sysstat-11.1.1/rndr_stats.h
- […]
- sysstat-11.1.1/activity.c
- sysstat-11.1.1/sar.c
- sysstat-11.1.1/iostat.c
- sysstat-11.1.1/rd_sensors.c
- sysstat-11.1.1/prealloc.in
- sysstat-11.1.1/sa2.in
- #
- #
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
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:
- # ./configure
- Check programs:
- . checking for gcc… gcc
- checking whether the C compiler works… yes
- checking for C compiler default output file name… a.out
- […]
- checking for ANSI C header files… (cached) yes
- checking for dirent.h that defines DIR… yes
- checking for library containing opendir… none required
- checking ctype.h usability… yes
- checking ctype.h presence… yes
- checking for ctype.h… yes
- checking errno.h usability… yes
- checking errno.h presence… yes
- checking for errno.h… yes
- […]
- Check library functions:
- . checking for strchr… yes
- checking for strcspn… yes
- checking for strspn… yes
- checking for strstr… yes
- checking for sensors support… yes
- checking for sensors_get_detected_chips in -lsensors… no
- checking for sensors lib… no
- . Check system services:
- . checking for special C
- compiler options needed for large files… no
- checking for _FILE_OFFSET_BITS value needed for large files… 64
- . Check configuration:
- […]
- Now create files:
- […]
- config.status: creating Makefile
- Sysstat version: 11.1.1
- Installation prefix: /usr/local
- rc directory: /etc/rc.d
- Init directory: /etc/rc.d/init.d
- Systemd unit dir:
- Configuration directory: /etc/sysconfig
- Man pages directory: ${datarootdir}/man
- Compiler: gcc
- Compiler flags: -g -O2
- #
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:
- # make
- –gcc -o sadc.o -c -g -O2 -Wall -Wstrict-prototypes -pipe -O2
- -DSA_DIR="/var/log/sa" -DSADC_PATH="/usr/local/lib/sa/sadc"
- -DUSE_NLS -DPACKAGE="sysstat"
- -DLOCALEDIR="/usr/local/share/locale" sadc.c
- gcc -o act_sadc.o -c -g -O2 -Wall -Wstrict-prototypes -pipe -O2
- -DSOURCE_SADC -DSA_DIR="/var/log/sa"
- -DSADC_PATH="/usr/local/lib/sa/sadc"
- -DUSE_NLS -DPACKAGE="sysstat"
- -DLOCALEDIR="/usr/local/share/locale" activity.c
- […]
- #
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:
- # make install
- mkdir -p /usr/local/share/man/man1
- mkdir -p /usr/local/share/man/man5
- mkdir -p /usr/local/share/man/man8
- rm -f /usr/local/share/man/man8/sa1.8*
- install -m 644 -g man man/sa1.8 /usr/local/share/man/man8
- rm -f /usr/local/share/man/man8/sa2.8*
- install -m 644 -g man man/sa2.8 /usr/local/share/man/man8
- rm -f /usr/local/share/man/man8/sadc.8*
- […]
- install -m 644 -g man man/sadc.8 /usr/local/share/man/man8
- install -m 644 FAQ /usr/local/share/doc/sysstat-11.1.1
- install -m 644 *.lsm /usr/local/share/doc/sysstat-11.1.1
- #
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