CSCI251 - Systems and Networks

Lab3 - Operating System Configuration

Wednesday Jan 27, 2009

Discussion

Introductory Comments

Debian has a handful of front ends for its underlying software package management, some for use at the command line and one fancy graphical interface (Synaptic) for use in the X Windows environment. Of course, the command line can be used with or without having X Windows installed. The basic idea is that there are software repositories available over the Internet for installing or updating software packages. There is a problem: some packages depend on others even down to the version level. For example, if you install a new software package (e.g. Apache) it will depend on other packages, sometimes on many other packages. So you need to ensure that these other packages (and that means the correct versions) get installed as well. The interdependence of software packages is sometimes called "dependency hell".

Debian was a pioneer in automating the correct handling of these dependencies. Nowadays, most Linux distributions have sophisticated tools, so the user is spared descending into "dependency hell", nearly all of the time. The package management tools you'll use are part of Debian's package management system, apt (Advanced Package Tool) which was originally a front end for the lower level tool dpkg (Package Manager for Debian). For our purposes the two capabilities of most interest are

Both the apt tools and dpkg will prove useful. At the command line, the commonly used commands are

Of these, apt-get will be deprecated here in favor of aptitude. Historically, apt-get was often used even though it was functionally inferior to aptitude. This was probably because many were uncomfortable with aptitude's ncurses environment (a poor man's gui) and did not realize it could be used on the command line in the same fashion as apt-get.

Software Package Repositories

Debian, like other Linux distributions, has various development branches. For Debian, these are:

Thus, at some point in the future,

These branches are available via the Internet in so called repositories. The Debian package management tools and repositories are designed to be used together to provide the dependency-aware software installation and update capabilities for Debian Gnu/Linux installations. How does your system know which repository to use? The list is kept in your file system at

/etc/apt/sources.list

and possibly in some similar files in the directory

/etc/apt/sources.list.d/

Instructions

From here on, we will refer to the virtual machine you set up in the previous lab as vbx as opposed to the host system on which it runs. On vbx you installed Debian 'lenny' distribution in the last lab.

This lab is to be performed with your vbx system. Consequently,

Task #0: Examine vbx's Hardware

Examine the 'hardware configuration' of vbx by using the information provided by the operating system (like we did in Lab 1).  Create a file vbx-hw.txt that contains the following information about vbx hardware: processor type, speed, cache, main memory, hard drives, network interface, etc.

Task #1: Check out vbx's Connectivity to the Outside

If you're going to update or add packages via the Internet, you had better first check out your Internet connection. To see which interfaces are configured, enter at your vbx console

/sbin/ifconfig eth0

You should see that your virtual machine has an Internet address for eth0 given by

inet addr: 10.0.2.15

and to find the gateway address, enter

/sbin/route

Now try ping, which is just a way to check if you can reach a certain address (some valid addresses may be configured to reject ping inquiries). To shut off ping once it's running, enter Ctrl-C.

Try to ping vbx itself

ping 10.0.2.15

0r equivalently

ping localhost

Then try the gateway

ping 10.0.2.2

Finally try the department's csciun1

ping csciun1.mala.bc.ca

Next try ssh (remote login using the secure shell). You might first try to contact your OS251 from your virtual machine, but what is the address of the host? Find out by using a terminal window on the host  and enter

/sbin/ifconfig

and find what it says for the inet addr of the eth0 interface. Represent that by xxx.xxx.xxx.xxx. Now try to login to host machine from the vbx screen via

ssh -l <your_OS251_username> xxx.xxx.xxx.xxx

for example, using a fictitious name and address,

ssh -l schwartzd 192.168.0.205

An example of alternative syntax is

ssh schwartzd@192.168.0.205

If you have an account on csciun1, try to ssh into that from vbx screen e.g.

ssh schwartzd@csciun1.mala.bc.ca

The upshot is that you can get to the outside Internet from within vbx i.e. the contact is initiated from vbx- as you did with ping and ssh. Without X Windows you could still use text based browsers, for example. Once X Windows is installed, you will be able to use more familiar graphical browsers.

The natural next question is, 'can one initiate contact from the outside and reach vbx?'. For example, one might want to ssh into vbx or perhaps use vbx as a dedicated web site. As first installed, a VirtualBox guest, such as vbx, cannot be contacted from the outside. However, in a later lab assignment you will change this. The phrase 'externally accessible' will require some further explanation since one cannot directly access the machines in Room 115 from the outside (but can, using csciun1 as an intermediary).

Task #2: Modify /etc/apt/sources.list

Note: The instructor will lead you through this section, so wait for his input. You'll typically be working at the superuser privilege level.

Move to the /etc/apt directory. View the content of the sources.list file using

        cat sources.list


Make a backup of the file as sources.list.bak. Now edit the sources.list file to contain the following ad save:

#

deb http://ftp.us.debian.org/debian/ lenny main contrib non-free
deb http://security.debian.org/ lenny/updates main contrib
deb-src http://security.debian.org/ lenny/updates main contrib
In a later section (Task #4) the aptitude command provided by apt will be described in some detail. That will be anticipated here by your first use of the command. In particular, enter

aptitude update

This checks the repositories to determine any packages in /etc/apt/sources.list that have been updated. This should be done before the next command. The update process may take a while, depending on the speed of your Internet connection and on how busy the repositories are currently. Once the package list has been updated, you can upgrade any installed packages which have available updates in the repositories by entering

aptitude upgrade

These two commands should be periodically exercised in this order, if you wish to keep your local installation up to date with maintenance and security updates.

Task #3: Before installing new software packages

Before you start installing packages, you might like to get answers to questions such as

The df command will report on disk file space availability. Try it and see what it reports. Then save the report in a text file e.g.

df > df0.txt

It should indicated that there is still plenty of available room on your virtual hard drive.

[Note: try this

df | tee df0.txt

and explain what it does differently than the above.]
 
To see which packages are currently installed on your system, ask dpkg to list them by entering dpkg -l. Then save what it reports in a file e.g.

dpkg -l > dpkg0.txt


These two files, df0.txt and dpkg0.txt tell us something about the initially installed system, and should be saved for future reference. The instructor will ask to see them at the end of the lab period. These files can be examined with an editor or via

cat dpkg0.txt | more

You might also want to know if a certain package is present. Let's say you wonder if the tiny text editor, nano, is present. To automate the search, you can use grep i.e.

dpkg -l | grep nano

or look at the file you created i.e.

cat dpkg0.txt | grep nano

You also might be curious about what a particular package provides. Let's say you look into dpkg0.txt and see the package cron.  To find out about cron from the apt database (or cache) we can use the aptitude command ( see the next section, Task #4) with option show

aptitude show cron

which tells us package data used by apt, but also describes the functionality provided by cron. If cron also has a man page, which it does, you can additionally get detailed information on its usage e.g. see

man cron

Packages can contain multiple files and to list those try dpkg -L, e.g.

dpkg -L cron

You can reverse this idea and ask from which package a particular file comes, by using  dpkg -S, e.g.

dpkg -S crontab

This simply searches for the crontab string and shows package names wherever that string is found. If the string is somewhat general, the search will occasionally give you extra information which may or may not be of interest at the moment.

Task #4: Install a selection of new software packages

Install using aptitude

Aptitude has historically handled orphaned dependencies, whereas apt-get and synaptic have not. For example, if you installed package A which depended on packges B and C, apt-get would install the needed dependent packages as well. But if you then removed package A with apt-get, packages B and C would be left behind (orphaned), not efficient. However, aptitude would correctly remove the orphaned packages. More recently, they all reportedly handle removal correctly with respect to orphaned packages. There is actually more syntax to learn with apt-get than with aptitude. Although some are put off by aptitude's ncurses interface, you need not use that; aptitude can be used at the command line. That said, the ncurses interface is powerful once mastered. The aptitude syntax follows:


Let's try to install some packages that we'll probably use later. Two might be
less and nmap, but double check; are they already present? Try

dpkg -l | grep nmap
dpkg -l | grep less

If they are not present, install them by entering these commands:

aptitude install nmap
aptitude install less

After these commands finish, check to see that dpkg reports their presence:

dpkg -l | grep nmap
dpkg -l | grep less

Note that

aptitude search nmap
aptitude search less

give broader information, some of which may useful.

What if after you installed nmap with

aptitude install nmap

you decided that you didn't mean to do that. You could remove it with

aptitude remove nmap or aptitude purge nmap

If you try that, reinstall nmap.

Check how much space we used with df to get a feel for disk usage. Try it by entering

df > |tee df1.txt

Calculate how many bytes were used to add these two packages by comparing df1.txt with df0.txt (created in Task #3). Record the change in number of bytes.

[Note: try this:

diff df1.txt df0.txt

and explain what it does.]

Task #5: Demonstration

In this section, you will demonstrate the mastery of the subject matter covered in this lab session. When ready, call on the instructor to come to your work station. You will then demonstrate the following:

From Task #0

From Task #1


From Task #2

aptitude update
aptitude upgrade

From Task #3

From Task #4

Shutdown

Once you have finished your demonstration, be sure that the instructor has recorded that fact.

Shutdown the virtual machine using the shutdown command.