installing software packages
finding information about packages
Both the apt tools and dpkg will prove useful. At the command line, the commonly used commands are
apt-get
aptitude
dpkg
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:
stable - a complete set of packages considered to be stable, currently named 'lenny'
testing - a complete set of packages undergoing testing, currently named 'squeeze'
unstable - a complete set of packages undergoing rapid development, currently named 'sid'
Thus, at some point in the future,
sid will move from unstable to testing
squeeze will move from testing to stable
lenny will move from stable to oldstable
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/
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).
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
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.
Before you start installing packages, you might like to get answers to questions such as
how much (virtual) hard disk room is available?
which packages are already installed?
what files does a package contain?
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.
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:
aptitude: Running it with no arguments brings up the ncurses interface to search, navigate, install, update and otherwise administer packages. There is a learning curve associated with it.
aptitude install: Install software for your system along with any needed dependencies.
aptitude remove: Remove packages as well as dependencies, thereby avoiding orpaned packages.
aptitude purge: Remove packages, their dependencies, as well as any related configuration files.
aptitude search: Search for packages in the local apt package lists.
aptitude update: Update the local packages lists.
aptitude upgrade: Upgrade any installed packages that have been updated.
aptitude clean: Delete any downloaded files necessary for installing the software on your system, which are no longer needed.
aptitude dist-upgrade: Upgrade packages, even if it means uninstalling certain packages.
aptitude show: Show details about a package name.
aptitude autoclean: Delete out-of-date packages, but keep current ones.
aptitude hold: Fix a package at its current version, and don't update it
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:
and explain what it does.]
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 #1
ping your host system
ssh to your host account
ping csciun1
ssh to your csciun1 account
From
Task #2
display the contents of your new /etc/apt/sources.list
display what happens upon entering
From Task #3
search your installed package list for nmap
next try entering man nmap at the command line
display df0.txt (recorded in Task #3)
enter df at the command line and compare the results to df0.txt, i.e. calculate the difference (in bytes) in virtual hard drive storage used
From Task #4
purge nmap
search your installed package list for nmap to see if it's gone
next try entering man nmap at the command line to see if the man page is also gone
install nmap
search your installed package list for nmap to see if it's back
next try entering man nmap at the command line to see if the man page is also back
Shutdown