CSCI 2150
Linux Package Installation Lab
The following set of steps takes you through the installation of
software using the Red Hat Package Manager. It uses the text-based
command line terminal, which due to the overwhelming majority of
programs that use a graphical user interface (GUI), may be unfamiliar
to most people.
For the most part, there are a few things you need to know about using the
terminal interface for Linux.
- There are two main ways to open the terminal interface.
- The first method, which may be different depending on which distribution
of Linux you installed and which desktop you are using, is to open the
terminal interface from the desktop menu. In Gnome running on Redhat 9.0,
you can select "System Tools" from the main menu then click
on "Terminal". This will bring up a terminal window on the desktop.
- The second method is the most reliable, but is also the most difficult
to use because it turns the entire desktop into a text screen. Simply
press CTRL-ALT-F1. To return to the desktop,
press ALT-F7.
- Each command will be entered one at a time by typing the command then pressing
Enter to execute the command. The up arrow and
down arrow can be used to scroll through previous commands.
- All Linux commands are case sensitive. Be sure to match the uppercase and
lowercase format used in all of the commands printed in this document. Be
careful to also match the spacing. This is where the majority of errors occur
in this lab.
- If you are typing the name of a file or a directory, Linux can help you
by filling in the rest of the name before you are finished. For example, assume
a directory/folder contains the following files:
private .txt
program
myfile.dat
If you are trying to type the name "myfile.dat", simply type 'm',
then press the tab key. Linux will fill in the rest of the name for you if
there is only one option. If there are more than one possible option, for
example if you typed "pr" then tab, Linux will beep at you to tell
you it cannot isolate which file you are referring to. Simply type an additional
letter, for example "pro", then tab, and Linux will finish the string
of characters
Important: Some of the operations you will be performing in this lab require
that you are logged in as the "superuser" or "root". If
you have not logged into your system as root, type su
at the command prompt. You will then be asked for the root password. After entering
it, you will be logged into the terminal as the superuser.
Make the DOS floppy visible to the Linux operating system
Linux treats everything including disk drives as subdirectories of "/".
Therefore, in order to read a floppy diskette, we need to make a directory for
the floppy drive to be visible through. To do this, we must create an empty
directory that we can mount to the floppy drive. (Mount simply means to connect
or enable the resource to make the it available.)
First, make the directory to connect the floppy to.
- Your installation of Linux may have already created this directory. (This
is because mounting a floppy drive is a common practice.) To find out if
this is the case, type ls /mnt. (Don't include the period; it was used simply
to complete the sentence.) You should see a list of names. If one of them
is "floppy", proceed to step 6. If "floppy" does not
appear or if you get the message "No such file or directory,"
go to the next step.
-
Move to the top directory in the directory structure by typing cd
/ then pressing Enter.
- I usually create a subdirectory called mount under which I add the directories
that I will be mounting my devices to. To do this, type mkdir
mnt then press Enter.
- Make the current or active directory the mount directory by typing cd
/mnt then pressing Enter.
- Now that you're inside the mount directory, we can create the directory
that we will be connecting the floppy to. Type mkdir
floppy then press Enter.
Now that we've created the directory to connect the floppy to,
we now need to tell Linux to go connect to the floppy. It is
important to note that in this case, our diskette is a Microsoft
DOS diskette, not a Linux diskette. It will be explained later
how to address this.
- Place the floppy disk that you received from me in the A-drive.
- Type mount -t vfat /dev/fd0 /mnt/floppy and press Enter.
- mount is the command to tell Linux to make the connection
between a device and a directory name
- -t vfat tells the mount command that the diskette is of
type vfat, i.e., it is a Microsoft DOS diskette.
- /dev/fd0 tells the mount command which device is being
connected to the directory. All Linux devices including
serial ports, printer ports, CDROMs, and hard drives have
names defined under the /dev directory.
- /mnt/floppy is the directory we created to connect the
diskette to.
Next, copy the file from the floppy that you'll need for this
installation.
- First, let's make the current or active directory the one that we defined
for the floppy. Type cd /mnt/floppy
then press Enter.
- To see what files are on this disk, type ls
-l then press Enter. (The character after the dash is a lowercase
L. The -l makes ls show the details of each of the files.) A list of the files
and folders that are contained in the top folder of the floppy should appear.
There should only be one file on the diskette you received. It is listed with
its modification date and time, the userid of the person who created the file,
and the privileges associated with the file.
- The command "cp" is used to copy files from one location to another.
Type cp faq-6.2-1.noarch.rpm
/root/ then press Enter. This will copy the file faq-6.2-1.noarch.rpm
to your directory /root.
- Lastly, to release the mounted floppy diskette from the operating system,
we must use the umount command. Before we can release it, we must be out of
the directory it is mounted to. Type cd
/ and Enter, then type umount
/mnt/floppy then press Enter. This must be done before you
eject the diskette.
Installing Software Using RPM
Although the installation seemed to take forever and it seems
like everything you'd ever need is included in your Linux installation,
you may want to install other applications or files later on. One of
the simplest ways to do this is to use a tool called the Red Hat
Package Manager (RPM).
Packages are groups of files including applications, settings,
configurations, etc. that the developer or distributor has compiled
into a single file for installation. (Not all Linux software comes
as a package.) The file that you copied to the /root directory was
a package, not of applications, but of HTML files. Specifically, it
is a set of HTML files that are Frequently Asked Questions (FAQs)
about Linux. Follow these steps to install the files.
- Change your current directory to /root by typing cd
/root the pressing Enter.
- Next, use the ls command to verify that the file faq-6.2-1.noarch.rpm was
successfully copied to the directory. Unless you've added other files to your
/root directory, it should be the only file present.
You will be using RPM to install these files. Some basic
formats of the RPM command are shown in the table below.
Command |
Action performed |
rpm -ivh packagename |
Install a package |
rpm -e applicationname |
Uninstall a package |
rpm -qa |
List all installed packages |
rpm -Va |
Check that all packages are installed correctly |
rpm -qpl packagename |
See the names of the files installed by the RPM |
rpm -qpi packagename |
Get general information about a package |
rpm -q -whatrequires filename |
Find out which packages rely on a file |
- Type rpm -qa
then press Enter. According to the table above, this will produce a list of
all of the packages that have been installed on your machine. There should
be quite a few of them.
- To install software, the table above indicates that we should use the command
rpm -ivh packagename where packagename is replaced with the name of the package
we wish to install. Type rpm
-ivh faq-6.2-1.noarch.rpm then press Enter. If the installation
was successful, you should see a line of text appear on your screen similar
to the one shown on the following page.
faq ########################################
Using the Installed Software
So where did it all go? In order to use the software,
it would be nice to know where RPM put it. According to
the table above, the command rpm -qpl packagename will list
all of the files installed by RPM where packagename is
replaced with the name of the package we installed.
- Type rpm -qpl faq-6.2-1.noarch.rpm
then press Enter. You should see a list of files fly by, and in that list
you should see that the HTML files were installed in a directory /usr/doc/FAQ/html.
- Change to this directory by typing cd
/usr/doc/FAQ/html and pressing Enter. Typing ls should reveal
all of the files that were installed here.
- The files that you installed comprise a set of FAQs on Linux topics. There
is a simple text-based HTML browser called lynx that you can use to view these
files. Type lynx Linux-FAQ.html
then press Enter to view them. Many of you may not have this browser
installed. In this case, use the graphical web browser that you access from
your desktop.
The following is a brief tutorial on the use lynx, a text only
browser that came with your installation of Linux.
- The up and down arrow keys highlight each link
- The right arrow follows that link to its referenced page
- The left arrow goes back to the previous page
- PgUp and PgDn scroll through the displayed document
- Q quits
Call me over to verify that your installation was successful.
If you wish to uninstall the HTML files that you just installed, type rpm
-e faq then press Enter. Note that faq is the package name,
the same name which was displayed when you installed the software.
Compressed Packages
Linux typically delivers groups of files and directories in a package that
has been compressed to reduce the overall size of the package. There are actually
two steps to restoring these files before they can be used on a Linux system.
To begin with, when a software developer has completed a set of files and is
ready to ship them, he or she groups them together using a program referred
to as tar. The name tar stands for "tape archive" and
was originally used to make it easier to move a large group of files as a whole.
The next thing the software developer does is to compress the "tar-ed"
file into a smaller package. The following file extensions are used to distinguish
the different types of files.
- filename.tar -- this is the format of a file name that has simply
been packaged but not compressed.
- filename.tar.gz or filename.tgz -- this is the format of a
file name that has been packaged and also compressed.
Therefore, in order to restore the files you have downloaded from a developer,
you must perform the reverse set of operations. First, you must uncompress the
files in order to retrieve the original tar file. Then, you must apply the tar
program in order to restore the files and directory structure that the developer
created.
- Using steps 6 through 9, mount the diskette containing the compressed and
archived file onto the /mnt/floppy directory
- Using the command "cp", copy the compressed and archived file
"shed-1.10.tar.gz" to the root directory. This is done by typing
cp /mnt/floppy/shed-1.10.tar.gz
/root/ then pressing Enter.
- Release the mounted floppy diskette from the operating system using the
"umount" command. Do this by entering the command cd
/ to get out of the floppy directory then entering the command
umount /mnt/floppy.
Remember that this must be done before you eject the diskette.
With the correct switches, later versions of tar can be used to uncompress
the package and unpack all of the files and directories.
- Move to the /root directory by typing cd
/root. (Do not include the period.)
- Now that the file has been copied this directory, uncompress it using the
command tar -xvzf shed-1.10.tar.gz.
(Do not include the period.)
- Take a directory using ls -l, and you should see a new directory/folder
has been created called shed-1.10. This contains all of the files we will
be using to install a simple application.
Using Make
The files you uncompressed in the previous section are for a program called
shed. Shed, which stands for "simple hex editor", will allow you to
open a file and view its contents in ASCII, hexadecimal, decimal, octal, and
binary. (You can download your own copy from the URL http://sourceforge.net/projects/shed.)
The following instructions show how to install shed from the downloaded package.
- To install it, move into the directory shed-1.10 by typing cd
shed-1.10.
- The installation instructions say to run the command ./configure
(the "./" tells Linux that the program or script that
you are running is in the same directory as the one you are currently in.).
This command prepares your files to be compiled into an application for your
system.
As a convenience to programmers and the end users who might be compiling software,
almost all software development environments come with a method to maintain
all of the settings including a list of all of the files needed to create an
application. For command line compilers, this operation is usually called "make".
When you installed the development packages for Linux, make came as part of
that package. The parameters for the make that you have on your Linux installation
are contained in a text file called "Makefile". (Type cat Makefile
to see these parameters sent to the screen.)
- To make your shed application, type the command make
while you are in the shed-1.10 directory.
- Typing ls -1 should
reveal a program called shed in your directory.
If you are interested in seeing shed run, type ./shed README to open the text
file README and see what the different characters are equal to in ASCII, hex,
decimal, octal, and binary.
Developed by David Tarnoff for all sections of CSCI 2150 at ETSU