Updated: 2012-11-28 15:49 EST

1 Topics and Readings (Fedora Textbook)Indexup to index

2 Software PackagesIndexup to index

A software package is a bundle of software and configuration files, plus some scripts used to install the software. A software package is a way of distributing software so that it can be easily installed, upgraded, queried, and deleted.

Package management systems take all the various files containing programs and data, documentation, and configuration information, and place them in one specially formatted file.

The advantage of having a package manager is that you do not have to compile the application on your system to install it. You simply need to have a compiled version of the package - usually called a pre-compiled binary created by someone who is generally more knowledgeable about compiling the package in its most optimized format. You can then install this compiled package/application through the package manager.

There are two main systems for package management: RPM and APT/DEB.

3 Two Worlds - RPM and APT/DEBIndexup to index

There are two main systems for managing packages:

You can sometimes convert one type of package to another, but other differences in the distributions may mean the package does not install correctly. Packages have version numbers, and are designed to work with certain other packages and distributions of Linux.

We will look mostly at RPM package managers this term. The Debian world uses apt-get and dpkg to manage its packages.

4 YUM - Yellowdog Updater Modified for RPMIndexup to index

YUM is a high-level package manager that works with RPM packages. It automatically installs or updates dependent software packages, so you don’t have to worry about the low-level RPM details. It can contact remote servers to fetch new packages as needed. Usage:

yum install package_name
yum install grub

yum remove package_name
yum remove grub

yum list             # list all packages that are available (thousands!)
yum search string    # list package names and descriptions matching string

yum check-updates    # list which packages have updates available
yum update [package] # update the given package (or all packages)

YUM is preferred over using the lower-level tools such as rpm that do not know how to use remote servers.

5 RPM - Red Hat Package ManagerIndexup to index

The rpm command is a low-level package manager. Most people use yum instead. RPM can access packages on remote servers using URLs, but it does not keep track of what is available as YUM does. You may need to use RPM to fix a broken system where YUM doesn’t work.

RPM has several major groups of options. We will look at Query options and Install options:

5.1 RPM - Query installed packagesIndexup to index

rpm -qa               # lists names of all packages currently installed
rpm -qf /bin/ls       # find which installed package "owns" a file

rpm -q package_name   # show full name of installed package with this name
rpm -q grub
rpm -qi grub          # display installed package information
rpm -ql grub          # lists most files installed by package
rpm -qR grub          # display dependencies of installed package

Some packages have “dependencies”; they depend on capabilities that are provided by other packages. If these dependencies are not respected, rpm will not let you install the package.

5.2 RPM - Install/Remove packagesIndexup to index

Note: Use the RPM Upgrade option instead of Install - it avoids package conflicts.

rpm -i package_file   # install the given RPM package_file
rpm -v -i dosfstools-2.11-8.fc7.i386.rpm

Upgrade is used to upgrade an existing package. It installs the current version of package and erases all previous versions. (Use Upgrade instead of Installation option to avoid conflicts.)

rpm -U package_file
rpm -v -U bash-3.2-20.fc8.i386.rpm

Uninstall (erase) a package:

rpm -e package_name
rpm -e grub

Be careful not to erase a package needed by other packages!

You can also use RPM to verify packages by comparing the installed versions of files with the versions distributed in the package.

6 Unix/Linux tar file (tarball)Indexup to index

Long before package managers such as YUM, RPM, and APT, there were “tar” archives. Originally written as a magnetic Tape ARchiver, the command is common to every Unix/Linux system. A “tar” archive file is the Unix version of a “zip” file. You can download and extract it on any Unix/Linux system back to 1969.

A “tar” archive, also called a “tarball”, is a single file that contains multiple uncompressed files and directories. Unix/Linux software source is often distributed as a “tarball”.

The syntax of the tar command is irregular - you don’t have to put dashes in front of the operation letters (but you can if you like):

tar <operation> [options] -f <output_file> [<pathnames>]
Example: tar -cf stuff.tar *.c
Example: tar cf my.tar .         # create archive of current directory
Example: tar -xvf my.tar         # extract everything into current dir
Example: tar xvf my.tar mydir    # only extract mydir from the archive

You must always use one of three major operation letters:

-t: list the pathnames in the archive
-x: extract (all or some) pathnames from the archive
-c: create a new tar archive (erases existing contents!)

You may optionally use some relevant options:

-f: select the output pathname (almost always used; must be last option)
-p: preserve permissions when extracting
-v: verbose (more messages about what is happening, or more detail)
-z: the entire archive is compressed (or uncompressed if extracting)

Tarballs may be compressed as a whole using the gzip command or by options to the “tar” command itself:

  $ tar cvf tarball.tar *.c      # create tarball.tar verbosely
  $ gzip tarball.tar             # compress into tarball.tar.gz

  $ tar cvzf tarball.tar.gz *.c  # do both of the above in one step

  $ tar tvf tarball.tar          # verbose table of contents (uncompressed)
  $ tar xvf tarball.tar          # extract contents (uncompressed)

  $ tar tzvf tarball.tar.gz      # verbose table of contents (compressed)
  $ tar xzvf tarball.tar.gz      # extract contents (compressed)

Tarballs will archive entire directories if you give them directories:

  $ cd                                # go to my home directory
  $ tar czf /tmp/homedir.tar.gz .     # archive everything into a file
  $ cd /some/backupdir
  $ tar xzpf /tmp/homedir.tar.gz      # extract the whole archive

The name of the tar archive can be anything; the suffixes are there simply for human readers to better know what the files contain.

Compressed tarballs have names such as *.tar.gz or *.tgz.

Author: 
| Ian! D. Allen  -  idallen@idallen.ca  -  Ottawa, Ontario, Canada
| Home Page: http://idallen.com/   Contact Improv: http://contactimprov.ca/
| College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/
| Defend digital freedom:  http://eff.org/  and have fun:  http://fools.ca/

Plain Text - plain text version of this page in Pandoc Markdown format

Campaign for non-browser-specific HTML   Valid XHTML 1.0 Transitional   Valid CSS!   Creative Commons by nc sa 3.0   Hacker Ideals Emblem   Author Ian! D. Allen