Practice: RPM and YUM package management

Solutions for setting up your Linux system and software

Return to exercises

The exact output from the various commands will vary depending on how your system is configured.

Solution for exercise 1. Install an RPM package

Listing 1 shows how.

Listing 1. Use the rpm command to install a package
[tbost@t60 ~]$ sudo yumdownloader rpl
[tbost@t60 ~]$ sudo rpm -ivh rpl-1.5.5-3.fc12.noarch.rpm 
Preparing...                ########################################### [100%]
   1:rpl                    ########################################### [100%]

The sequence of steps in exercise 1 is as follows:

  1. As sudo user, use the yumdownloader command to download the RPM file.

    Depending on your Linux distribution, the package name may vary. Alternatively, you could download the package from a reputable mirror site.

  2. As sudo user, use the rpm -ivh command to install the file.

    The i instructs an installation. The v signals verbose output, while the h flag displays progress as a series of hashes during installation.

Note: Depending upon your Linux distribution and method of download, the rpl version may differ from what is shown in Listing 1.

Solution for exercise 2. Use RPM to query for information

Listing 2 shows the way to proceed.

Listing 2. Use the rpm -q command to query
[tbost@t60 ~]$ rpm -q rpl
rpl-1.5.5-3.fc12.noarch
[tbost@t60 ~]$ rpm -ql rpl
/usr/bin/rpl
/usr/share/doc/rpl-1.5.5
/usr/share/doc/rpl-1.5.5/COPYING
/usr/share/man/man1/rpl.1.gz
[tbost@t60 ~]$ rpm -qf /bin/ls
coreutils-8.5-7.fc14.i686

The sequence of steps in exercise 2 is as follows:

  1. Use the rpm -q rpl command to query whether the package is installed.

    If rpl is not installed, the output will display package rpl is not installed.

  2. Use the rpm -ql rpl command to list all files owned by the rpl package.
  3. Use the rpm -qf /bin/ls command to return the package that owns the /bin/ls file.

    The /bin/ls file is owned by the coreutils package.

Note: Root or sudo privileges are not required to perform queries on the RPM database. Depending upon your Linux distribution, the rpl version may differ from Listing 2.

Solution for exercise 3. Use RPM to remove a package

Listing 3 shows the command to use.

Listing 3. Use the rpm command to remove a package
[tbost@t60 ~]$ sudo rpm -e rpl
[tbost@t60 ~]$

Type the command sudo rpm -e rpl to remove the package. The e is for erase. A successful removal returns to the shell with no errors, as indicated in Listing 3.

Solution for exercise 4. Use YUM to find information about software

Listing 4 shows how to go about it.

Listing 4. Install software with YUM
[tbost@t60 ~]$ yum list tcsh
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
Available Packages
tcsh.i686 
[tbost@t60 ~]$ yum info tcsh
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
Available Packages
Name        : tcsh
Arch        : i686
Version     : 6.17
Release     : 12.fc14
Size        : 404 k
Repo        : updates
Summary     : An enhanced version of csh, the C shell
URL         : http://www.tcsh.org/
License     : BSD
Description : Tcsh is an enhanced but completely compatible version of csh, the C
            : shell.  Tcsh is a command language interpreter which can be used both
            : as an interactive login shell and as a shell script command processor.
            : Tcsh includes a command line editor, programmable word completion,
            : spelling correction, a history mechanism, job control and a C language
            : like syntax.

[tbost@t60 ~]$ yum deplist tcsh
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
Finding dependencies: 
package: tcsh.i686 6.17-8.fc14
  dependency: rtld(GNU_HASH)
   provider: glibc.i686 2.12.90-17
   provider: glibc.i686 2.13-1
  dependency: libc.so.6(GLIBC_2.3)
   provider: glibc.i686 2.12.90-17
   provider: glibc.i686 2.13-1
  dependency: libc.so.6
   provider: glibc.i686 2.12.90-17
   provider: glibc.i686 2.13-1
  dependency: libc.so.6(GLIBC_2.1)
   provider: glibc.i686 2.12.90-17
   provider: glibc.i686 2.13-1
  dependency: libc.so.6(GLIBC_2.0)
   provider: glibc.i686 2.12.90-17
   provider: glibc.i686 2.13-1
  dependency: grep
   provider: grep.i686 2.7-1.fc14.1
   provider: grep.i686 2.7-2.fc14
  dependency: libc.so.6(GLIBC_2.3.4)
   provider: glibc.i686 2.12.90-17
   provider: glibc.i686 2.13-1
  dependency: libcrypt.so.1(GLIBC_2.0)
   provider: glibc.i686 2.12.90-17
   provider: glibc.i686 2.13-1
  dependency: libcrypt.so.1
   provider: glibc.i686 2.12.90-17
   provider: glibc.i686 2.13-1
  dependency: /bin/sh
   provider: bash.i686 4.1.7-3.fc14
.....
.....
......
[tbost@t60 ~]$

The sequence of steps in task 1 is as follows:

  1. Use the yum list tcsh command to query the availability of tcsh.

    If you are unsure of a package's name, you could alternatively use the yum search command.

  2. Once you know the software's name, use the yum info tcsh command to query more detailed information, such as licensing, software size, available version, and a description of the software's purpose.
  3. Use the yum deplist tcsh command to query the needed dependencies for available software.

    A nice function of YUM that is not available with the rpm command is the ability to find and install dependencies.

Note: As with the rpm command, neither root nor sudo privileges are required to perform queries with YUM. Depending on your Linux distribution, versions may vary for software shown in Listing 4.

Solution for exercise 5. Use YUM to install software

Listing 5 shows the expected input and output.

Listing 5. Install software with dependencies
[tbost@t60 ~]$ sudo yum install tcsh
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package tcsh.i686 0:6.17-12.fc14 set to be installed
--> Finished Dependency Resolution

Dependencies Resolved

.....
.....
.....
.....

Install       1 Package(s)

Total download size: 404 k
Installed size: 1.1 M
Is this ok [y/N]: y

As sudo, type sudo yum install tcsh to install tcsh along with any required dependencies that are not all ready installed. Notice that the final line in Listing 5 shows that YUM needs your approval before it attempts to install any software. The default value is n, so you must explicitly type y to complete the installation. Alternatively, you could type sudo yum install -y tcsh to instruct YUM to automatically download and install the software.

Note: Depending on your Linux distribution, the version may vary for software shown in Listing 5.

Solution for exercise 6. Use YUM to remove software

Listing 6 gives the solution.

Listing 6. Remove software with yum
[tbost@t60 ~]$ sudo yum remove tcsh
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package tcsh.i686 0:6.17-12.fc14 set to be erased
--> Finished Dependency Resolution

Dependencies Resolved

........
........
........

Installed size: 1.1 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing  : tcsh-6.17-12.fc14.i686   1/1

Removed:
  tcsh.i686 0:6.17-12.fc14                                                            

Complete!
[tbost@t60 ~]$

As sudo, type sudo yum remove tcsh to remove tcsh along with any dependencies that have been installed with it and are no longer required by any current software on your computer. Notice again in Listing 6 that YUM wants your approval before it attempts to remove any software. The default is n, so you must explicitly type y to complete the removal process. Alternatively, you could type sudo yum remove -y tcsh to instruct removal with no prompt.

Note: Depending on your Linux distribution, the version may vary for software shown in Listing 6.

Return to exercises