Home » , » Installing and Updating Applications in Linux

Installing and Updating Applications in Linux

Written By Sajib Barua on Sunday, August 19, 2012 | 12:22 PM

previous Managing File Systems in Linux
Most software packages for Linux are distributed in one of two special file formats: Red Hat Package Manager (RPM) files or Debian (DEB) files. That’s why you have to know how to install or remove software packages that come in the form of RPM or DEB files. This chapter illustrates how to work with both types of files.
You can install RPM and DEB files in all Linux distributions, but each distribution has its favored distribution format. Fedora, with its Red Hat Linux heritage, favors RPM files, whereas most Debian-based distributions, such as Knoppix, Ubuntu, and Xandros, use DEB files for distributing software. SUSE Linux uses RPM format.
Many other open source software packages come in source-code form, usually in compressed archives. You have to unpack, build, and install the software to use it. The following sections describe the steps you typically follow when downloading, building, and installing source-based software packages. There is also a brief description of how to update your Linux system online. As you’ll find out, each distribution has its own tools for online updates.
Working with RPM Files
RPM is a system for packaging all the necessary files for a software product in a single file — called an RPM file, or simply, an RPM. In fact, the Fedora and SUSE distributions are a whole lot of RPMs. The best way to work with RPMs is through the RPM commands. You have to type these commands at the shell prompt in a terminal window or a text console.
In Fedora, the RPM commands are suitable only if you have to install just a handful of RPM files. To install a large number of RPM files, you should choose Applications➪Add/Remove Software from the desktop. If you install RPM files from a CD or DVD, first mount the CD/DVD and then type systemcdinstall-helper /media/cdrom. (If your CD/DVD is mounted at some other directory, replace /media/cdrom with that directory name.) You’ll see a Package Management window from which you can select and install groups of packages.
Using the RPM command
When you install an RPM-based distribution such as Fedora, the installer uses the rpm command to unpack the packages (RPM files) and to copy the contents to your hard drive.
You don’t have to understand the internal structure of an RPM file, but you need to know how to use the rpm command to work with RPM files. Here are some of the things you can do with the rpm command:
  • Find out the version numbers and other information about the RPMs installed on your system.
  • Install a new software package from an RPM. For example, you may install a package you skipped during the initial installation.
  • Remove (uninstall) unneeded software you previously installed from an RPM. You may uninstall a package to reclaim the disk space, if you find that you rarely (or never) use the package.
  • Upgrade an older version of an RPM with a new one. For example, in Fedora, you may upgrade after you download a new version of a package from Fedora download sites (listed online at http://mirrors.fedora project.org). You must upgrade an RPM to benefit from the fixes in the new version.
  • Verify that an RPM is in working order. You can verify a package to check that all necessary files are in the correct locations.
As you can see, the rpm command is versatile — it can do a lot of different things, depending on the options you use.
If you ever forget the rpm options, type the following command to see a list:
rpm --help | more
The number of rpm options will amaze you!
Understanding RPM filenames
An RPM contains a number of files, but it appears as a single file on your Fedora system. By convention, the RPM filenames have a specific format. A typical RPM filename looks like this:
openoffice.org-writer-1.9.104-2.i386.rpm
This filename has the following parts, the first three of which are separated by hyphens (-):
  • Package name: openoffice.org-writer
  • Version number: 1.9.104
  • Release number: 2
  • Architecture: i386 (this package is for Intel 80x86 or Pentium-compatible processors)
Usually, the package name is descriptive enough for you to guess what the RPM may contain. The version number is the same as that of the software package’s current version number (even when it’s distributed in some other form, such as a tar file). Developers assign the release number to keep track of changes. The architecture is i386, or noarch, for the RPMs you want to install on a PC with an Intel x86-compatible processor.
Querying RPMs
As the rpm command installs packages, it builds a database of installed RPMs. You can use the rpm -q command to query this database to find information about packages installed on your system.
For example, to find out the version number of the Linux kernel installed on your system, type the following rpm -q command:
rpm -q cups
You see a response similar to the following:
cups-1.4.1-15
The response is the name of the RPM for the kernel. (This version is the executable version of the kernel, not the source files.) The name is the same as the RPM filename, except that the last part — .i386.rpm — isn’t shown. In this case, the version part of the RPM tells you that you have CUPS (the Common UNIX Printing System) version 1.4.1 installed.
You can see a list of all installed RPMs by using the following command:
rpm -qa
You see a long list of RPMs scroll by your screen. To view the list one screen at a time, type
rpm -qa | more
If you want to search for a specific package, feed the output of rpm -qa to the grep command. For example, to see all packages with kernel in their names, type
rpm -qa | grep kernel
The result depends on what parts of the kernel RPMs are installed on a system.
You can query much more than a package’s version number with the rpm -q command. By adding single-letter options, you can find out other useful information. For example, try the following command to see the files in the CUPS package:
rpm -ql cups
Here are a few more useful forms of the rpm -q commands to query information about a package. (To use any of these rpm -q commands, type the command, followed by the package name.)
  • rpm -qc: Lists all configuration files in a package.
  • rpm -qd: Lists all documentation files in a package. These are usually the online manual pages (also known as man pages).
  • rpm -qf: Displays the name of the package (if any) to which a specified file belongs.
  • rpm -qi: Displays detailed information about a package ( version number, size, installation date, and a brief description).
  • rpm -ql: Lists all the files in a package. For some packages, you see a very long list.
  • rpm -qs: Lists the state of all files in a package. (The state of a file can be one of the following: normal, not installed, or replaced.)
These rpm commands provide information about installed packages only. If you want to find information about an uninstalled RPM file, add p to the command-line option of each command. For example, to view the list of files in the RPM file named rdist-6.1.5-792.i586.rpm, go to the directory where that file is located and type the following command:
rpm -qpl rdist-*.rpm
This command works only if the current directory contains that RPM file.
Two handy rpm -q commands enable you to find out which RPM file provides a specific file and which RPMs need a specified package. To find out the name of the RPM that provides a file, use the following command:
rpm -q --whatprovides filename
For example, to see which RPM provides the file /etc/vsftpd.conf, type rpm -q --whatprovides /etc/vsftpd.conf
RPM then prints the name of the package that provides the file, like this:
vsftpd-2.0.3-1
If you provide the name of a package instead of a filename, RPM displays the name of the RPM package that contains the specified package. On the other hand, to find the names of RPMs that need a specific package, use the following command:
rpm -q --whatrequires packagename
For example, to see which packages need the openssl package, type rpm -q --whatrequires openssl
The output from this command shows all the RPM packages that need the openssl package.
Installing an RPM
To install an RPM, use the rpm -i command. You have to provide the name of the RPM file as the argument. If you want to view the progress of the RPM installation, use rpm -ivh. A series of pound signs (#) displays as the package is unpacked.
For example, to install the kernel-devel RPM (which contains the header files for the Linux operating system) for Fedora from the companion DVDROM, insert the DVD, and after it’s mounted, type the following commands:
cd /media/cdrom/Fedora/RPMS
rpm -ivh kernel-devel*
You don’t have to type the full RPM filename — you can use a few characters from the beginning of the name followed by an asterisk (*). Make sure you type enough of the name to identify the RPM file uniquely.
If you try to install an RPM that’s already installed, the rpm -i command displays an error message. To force the rpm command to install a package even if errors are present, add --force to the rpm -i command, like this:
rpm -i --force man-2*
Removing an RPM
You may want to remove — uninstall — a package if you realize that you don’t need the software. For example, if you have installed the X Window System development package but discover you’re not interested in writing X applications, you can easily remove the package by using the rpm -e command.
For example, to remove the package named qt3-devel, type rpm -e qt3-devel
You have to know the name of the package before you can remove it. One good way to find the name is to use rpm -qa with grep to search for the appropriate RPM file.
To remove an RPM, you don’t need the full RPM filename; all you need is the package name — the first part of the filename up to the hyphen (-) before the version number.
The rpm -e command does not remove a package that other packages need.
Upgrading an RPM
Use the rpm -U command to upgrade an RPM. You must provide the name of the RPM file that contains the new software. For example, if you have version 1.1.20 of CUPS (printing system) installed but want to upgrade to version 1.1.23, download the RPM file cups-1.1.23-15.i386.rpm from a repository and use the following command:
rpm -U cups-1.1.23-15.i386.rpm
The rpm command performs the upgrade by removing the old version of the CUPS package and installing the new RPM.
Whenever possible, upgrade rather than remove the old package and install a new one. Upgrading automatically saves your old configuration files, so you don’t have to reconfigure the software after a fresh installation.
When you’re upgrading the kernel packages that contain a ready-to-run Linux kernel, install it by using the rpm -i command (instead of the rpm –U command). That way, you won’t overwrite the current kernel.
Verifying an RPM
If you suspect that a software package isn’t properly installed, use the rpm -V command to verify it. For example, to verify the kernel package, type the following:
rpm -V kernel
rpm compares the size and other attributes of each file in the package against those of the original files. If everything verifies correctly, the rpm -V command does not print anything. If it finds any discrepancies, you see a report of them. For example, the command to type to verify the httpd package is
rpm -V httpd
The result may resemble the following:
S.5. . . . T c /etc/httpd/conf/httpd.conf
In this case, the output from rpm -V shows that a configuration file has changed. Each line of this command’s output has three parts:
  • The line starts with eight characters: Each character indicates the type of discrepancy found. For example, S means the size is different, and T means the time of last modification is different. Table 4-1 shows each character and its meaning. A period means that that specific attribute matches the original.
  • For configuration files, a c appears next; otherwise, this field is blank. That’s how you can tell whether a file is a configuration file. Typically, you don’t worry if a configuration file has changed; you probably made the changes yourself.
  • The last part of the line is the full pathname of the file. From this part, you can tell exactly where the file is located.
Table 4-1
Characters Used in RPM Verification Reports
Character
Meaning
S
Size has changed
M
Permissions and file type are different
5
Checksum computed with the MD5 algorithm is different
D
Device type is different
L
Symbolic link is different
U
Files user is different
G
Files group is different
T
Files modification time is different

Working with DEB Files
Debian packages with .deb file extensions store executable files together with configuration files, online documentation, and other information. You can unpack and manipulate these DEB files using the Debian utility dpkg, which is a command-line program that takes many options. A text mode, menu-driven program called dselect is also available for you to manage the packages without having to type dpkg commands.
You typically use a higher-level utility called APT (Advanced Packaging Tool) to work with packages in Debian. For example, instead of downloading a DEB file and installing it with the dpkg command, you can simply use the apt-get command to install the package. The apt-get command can even download the package from an online Debian repository and install it on your system. The dpkg command is still useful when you want to look at the contents of a DEB file that you have manually downloaded from a repository or that might be in the apt cache directory (/var/cache/apt/archives in Debian). dpkg, dselect, and apt are described in the following sections.
Understanding DEB filenames
A typical DEB package has a filename like the following:
mozilla-firefox_1.0.4-2_i386.deb
The filename has three parts separated by underscores (_):
  • Package name: mozilla-firefox
  • Version and revision: 1.0.4-2 (the first part is the package maintainer’s version number; the second part is the Debian revision number)
  • Architecture: i386 (the package is for Intel x86-compatible systems) The filename has a .deb extension, which indicates that this is a DEB file.
Using the dpkg command
To get a feel for the dpkg command, type dpkg --help | more. The output shows the large number of options that dpkg accepts. You can also type man dpkg to read the online man page for dpkg.
You can use dpkg to perform many operations on packages, but you have to work at a shell prompt in a terminal window or a text console. The format of a dpkg command is
dpkg [options] action package
The command has zero or more options, an action indicating what dpkg has to do, and the name of a package, a DEB file, or a directory (depending on the action argument). Sometimes the dpkg command does not need any name of package or file, just an action.
Here are some examples of actions you can perform with dpkg:
  • Install a package from a DEB file with the command dpkg -i package file, where packagefile is the name of the DEB file (for example, vsftpd-*.deb).
  • Remove a package but retain the configuration files with the command dpkg -r packagename, where packagename is the name of the package (for example, vsftpd)
  • Configure a package with the command dpkg --configure package name, where packagename is the name of a package (for example, vsftpd)
  • Purge — remove everything including the configuration files — with the command dpkg -P packagename, where packagename is the name of a package (for example, vsftpd)
  • Audit packages (and find the ones that are partially installed on your system) with the command dpkg -C (does not need a file or package name)
  • List contents of a DEB file with the command dpkg -c package file, where packagefile is the name of the DEB file (for example, vsftpd-*.deb)
  • View information about a DEB file with the command dpkg -I package file, where packagefile is the name of the DEB file (for example, vsftpd-*.deb)
  • List packages matching pattern with the command dpkg -l pattern, where pattern is the package name pattern — usually with wildcard characters — that you want to match (for example, kernel*)
  • Find packages that contain files with the command dpkg -S pattern, where pattern is the filename pattern — usually with wildcard characters — that the package contains (for example, stdio*)
  • List files installed from a package with the command dpkg -L package name, where packagename is the name of a package (for example, vsftpd)
You can try these commands on a Debian system or any system that uses DEB packages. For example, to look for all packages matching names that begin with mozilla, type dpkg -l mozilla* in a terminal window. Here is the relevant portion of this command’s output on a Debian system:
||/ Name Version Description
+++-==============-==========-============================================
un mozilla <none> (no description available)
un mozilla-bonobo <none> (no description available)
ii mozilla-browse 1.7.8-1 The Mozilla Internet application suite - cor
ii mozilla-firefox 1.0.4-2 lightweight web browser based on Mozilla

The ii in the first column indicates that the package is installed; un means the package is not installed.
Another common use of dpkg -l is to list all packages and use grep to find lines that match a search string. For example, to find anything containing kernel, type dpkg -l | grep kernel. If the package names (in the second column of the dpkg -l output) are truncated, adjust the width of the output lines with a command like this:
COLUMNS=132 dpkg -l | grep kernel
The dpkg -S command is a handy way to locate which package provided a specific file in the system. For example, if you want to figure out what package includes the /etc/host.conf file, type dpkg -S /etc/host.conf and the output shows that the base-files package contains /etc/host.conf:
base-files: /etc/host.conf
Introducing dselect
The dselect is meant to be a front-end to the dpkg utility. To try out dselect, log in as root and type dselect in a terminal window (or a text console). When dselect starts, you get dselect’s text mode menu.
dselect is not described in detail, but here are some of the tasks you can perform from the dselect main menu:
  • Specify an access method — how to find the DEB packages
  • Update the list of available packages
  • View the status of installed and available packages
  • Select packages and manage dependencies among packages
  • Install new packages or upgrade existing ones to newer versions
  • Configure packages that are not yet configured
  • Remove packages
One common sequence in dselect is to update the list of available packages and then upgrade all packages for which updates are available. You can, of course, perform that same task with a simple apt command as well.
Using APT to manage DEB packages
APT is truly an advanced utility for keeping your Debian system up-to-date. You can use a number of APT utilities to manage DEB packages. The two commonly used commands are apt-get and apt-cache.
To install a package with apt-get, simply type apt-get install package name, where packagename is the name of the package that you want to install. For example, to install the vsftpd package, type apt-get install vsftpd.
Removing a package is equally simple. Type apt-get remove package name, where packagename is the name of the package you want to remove.
If you want to find the name of a package and you know some terms associated with the package, you can look for it with the apt-cache utility. For example, to look for a CD/DVD burner package, type apt-cache search burn | more to search through the APT’s package cache (which is the list of Debian packages that APT downloads from the servers listed in the /etc/apt/sources.list file). Here are some lines of output from that command:
arson - KDE frontend for burning CDs
burn - Command line Data-CD, Audio-CD, ISO-CD, Copy-CD writing tool
caca-utils - text mode graphics utilities
cdcontrol - A parallel burner that allow you to write to one or more CD-Writers
at once
cdlabelgen - generates front cards and tray cards for CDs and DVDs
cdrtoaster - Tcl/Tk front-end for burning cdrom
cdw - Tool for burning CD’s - console version
cdw-common - Tool for burning CD’s - common files
cpuburn - a collection of programs to put heavy load on CPU
cwcdr - Chez Wam CD Ripper
dvd+rw-tools - DVD+-RW/R tools
dvdbackup - tool to rip DVD’s from the command line
edenmath.app - Scientific calculator for GNUstep
gcdw - Tool for burning CD’s - graphical version
gcombust - GTK+ based CD mastering and burning program
. . . lines deleted . . .

The output shows several potential CD/DVD burning programs that could be installed. To discover more about any of the packages, type apt-cache show packagename, where packagename is the name of the package for which you want information. For example, to find out more about the dvd+rw-tools package, type apt-cache show dvd+rw-tools and the output shows a description of the package. You can then install the package with apt-get install.
To search for a keyword that appears in the package’s name only, use the --names-only option like this: apt-cache search - -names-only keyword, where keyword is something that appears in the package’s name. For example, if you want to find packages that contain selinux in their names, type apt-cache search - -names-only selinux.
Run apt-get clean periodically to clean out the local repository (in the /var/cache/apt/archives directory) of DEB files that have already been installed. You can free up some disk space by removing these DEB files.
Building Software Packages from Source Files
Many open source software packages are distributed in source-code form, without executable binaries. Before you can use such software, you have to compile the source files to build the executable binary files and then follow some instructions to install the package. This section shows you how to build software packages from source files.
Downloading and unpacking the software
Typically, open source software source files are distributed in compressed tar archives. These archives are created by the tar program and compressed with the gzip program. The distribution is in the form of a single large file with the .tar.gz or .tar.Z extension — often referred to as a compressed tarball. If you want the software, you have to download the compressed tarball and unpack it.
Download the compressed tar file by using anonymous FTP or going through your Web browser. Typically, this process involves no effort on your part beyond clicking a link and saving the file in an appropriate directory on your system.
To try your hand at downloading and building a software package, you can practice on the X Multimedia System (XMMS) — a graphical X application for playing MP3 and other multimedia files. XMMS is bundled with Fedora and already installed on your system. However, you do no harm in downloading and rebuilding the XMMS package again.
Download the source files for XMMS from www.xmms.org/download.php. The files are packed in the form of a compressed tar archive. Click the http link for the source files and save them in the /usr/local/src directory in your Linux system. (Be sure to log in as root; otherwise you cannot save in the /usr/local/src directory.)
After downloading the compressed tar file, examine the contents with the following tar command:
tar ztf xmms*.gz | more
You see a listing similar to the following:
xmms-1.2.10/
xmms-1.2.10/intl/
xmms-1.2.10/intl/ChangeLog
xmms-1.2.10/intl/Makefile.in
xmms-1.2.10/intl/config.charset
xmms-1.2.10/intl/locale.alias
xmms-1.2.10/intl/ref-add.sin
xmms-1.2.10/intl/ref-del.sin
xmms-1.2.10/intl/gmo.h
xmms-1.2.10/intl/gettextP.h
xmms-1.2.10/intl/hash-string.h
xmms-1.2.10/intl/loadinfo.h
. . . lines deleted . . .

The output of this tar command shows you what’s in the archive and gives you an idea of the directories that are created after you unpack the archive. In this case, a directory named xmms-1.2.10 is created in the current directory, which, in this case, is /usr/local/src. From the listing, you also figure out the programming language used to write the package. If you see .c and .h files, the source files are in the C programming language, which is used to write many open source software packages.
To extract the contents of the compressed tar archive, type the following tar command:
tar zxvf xmms*.gz
You again see a long list of files as they are extracted from the archive and copied to the appropriate directories on your hard drive.
Now you’re ready to build the software.
Building the software from source files
After you unpack the compressed tar archive, all source files are in a directory whose name is usually that of the software package with a version number suffix. For example, the XMMS version 1.2.10 source files extract to the xmms-1.2.10 directory. To start building the software, change directories with the following command:
cd xmms*
You don’t have to type the entire name — the shell can expand the directory name and change to the xmms-1.2.10 directory.
Nearly all software packages come with a README or INSTALL file — a text file that tells you how to build and install the package. XMMS is no exception; it comes with a README file you can peruse by typing more README. An INSTALL file contains instructions for building and installing XMMS.
Most open source software packages, including XMMS, also come with a file named COPYING. This file contains the full text of the GNU General Public License (GPL), which spells out the conditions under which you can use and redistribute the software. If you’re not familiar with the GNU GPL, read this file and show the license to your legal counsel for a full interpretation and an assessment of applicability to your business.
To build the software package, follow the instructions in the README or INSTALL file. For the XMMS package, the README file lists some of the prerequisites (such as libraries) and tells you what commands to type to build and install the package. In the case of XMMS, the instructions tell you to use the following steps:
  1. Type ./configure to check your system’s configuration. This command also runs a shell script that creates a file named Makefile — a file the make command uses to build and install the package. (You can type ./configure --help to see a list of options that configure accepts.)
    If you get any errors about missing packages, you have to install those missing packages. Use your distribution’s software installation tools to add the missing packages. For example, in Debian use the apt-get install command. In Fedora, choose Applications»Add/Remove Software. In SUSE, use the YaST GUI tool.
  2. Type make to build the software. This step compiles the source files in all the subdirectories. (Compiling source code converts each source file into an object file — a file containing binary instructions that your PC’s processor can understand.)
  3. Type make install to install the software. This step copies libraries and executable binary files to appropriate directories on your system.
Although the preceding list is specific to XMMS, most other packages follow these steps: configure, make, and make install. The configure shell script guesses system-dependent variables and creates a Makefile with commands needed to build and install the software.
To use these simple commands to build software packages, you must first install the software-development tools on your system. In Fedora, you must install the Development Tools and the GNOME Software Development packages. In Debian, to build and run XMMS, you must also install the X Software Development package because XMMS is an X application.
After you’ve installed XMMS, try running it from the GNOME or KDE desktop by typing xmms in a terminal window. From the XMMS window, press L to get the Load File dialog box. Select an MP3 file to play. Your PC must have a sound card, and the sound card must be configured correctly for XMMS to work.
To summarize, here’s an overview of the steps you follow to download, unpack, build, and install a typical software package:
  1. Use a Web browser to download the source code, usually in the form of a .tar.gz file, from the anonymous FTP site or Web site.
  2. Unpack the file with a tar zxvf filename command. (If the compressed tar file has a .bz2 extension, that means the file is compressed with bzip2 and you can unpack that file with a tar jxvf filename command.)
  3. Change the directory to the new subdirectory where the software is unpacked, with a command such as cd software_dir.
  4. Read any README or INSTALL files to get a handle on any specific instructions you must follow to build and install the software.
  5. The details of building the software may differ slightly from one software package to another, but typically you type the following commands to build and install the software:
    ./configure
    make
    make install
  6. Read any other documentation that comes with the software to find out how to use the software and whether you must configure the software further before using it.
Installing SRPMs
If you have the source CDs for Fedora (you can download the source CD images from one of the sites listed at http://mirrors.fedoraproject. org), you can install the source files and build various applications directly from the source files. Fedora source-code files, like the executable binary files, also come in RPMs, and these source-code RPM files are generally known as SRPMs (source RPMs).
To install a specific source RPM and build the application, follow these steps:
  1. Mount the DVD-ROM by typing mount /media/cdrom or wait for the GNOME desktop to mount the DVD.
  2. Typically, source RPMs are in the SRPMs directory. Change to that directory by typing the following command: cd /media/cdrom/SRPMS
  3. Install the source RPM file by using the rpm -i command. For example, to install the Web server (httpd) source, type rpm -ivh httpd*.src.rpm
    The files are installed in the /usr/src/packages/SOURCES directory. A spec file with the .spec extension is placed in the /usr/src/packages/SPECS directory. The spec file describes the software and contains information used to build and install the software.
  4. Use the rpmbuild command with the spec file to build the software and install the binary files.
    You perform different tasks, from unpacking the source files to building and installing the binaries by using different options with the rpmbuild command. For example, to process the entire spec file, type:
    rpmbuild -ba packagename.spec
    where packagename is the name of the SRPM. This command builds the software and installs the binary files.
next Updating Linux Applications Online
Share this article :

0 comments:

Post a Comment

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Linux - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger