8.9. Administration of Packages

In order to install packages, you need to define where you want to get them from, where your package reservoir is.

You define your package reservoir in the file /etc/apt/sources.list

You can either work with package administration via the command line or with the help of a graphical application such as KPackage Section 13.6, or Webmin Section 13.1

A quick introduction to the use of the command line for working with packaqe administration is given in this section.


deb ftp://ftp.skolelinux.no/debian/ woody main contrib non-free
deb ftp://ftp.skolelinux.no/debian-non-US/ woody/non-US main contrib non-free
deb ftp://ftp.skolelinux.no/skolelinux/ woody local

These lines contain information about where you can get your packaqes.

If you add new lines to this file, then you have to update the database that contains information about what is available.

See Chapter 14 for other lines that you can add as sources for packages.

8.9.1. Updating the Database with Info About Available Packages

The selection of available packages changes constantly. New packages become available; newer versions of packages appear, etc. So it is necessary to make sure that the database that contains information about the packages is kept constantly up-to-date. This is done with the command

apt-get update

It's a good habit to always run this command before you upgrade or add new packages.

8.9.2. Upgrading All Installed Packages to a Newer Version

All of the packages that have already been installed can be upgraded to a newer version with the command

apt-get upgrade

Warning

Sometimes it's really nice to know what is actually going to happen before you start to upgrade all installed packages. It's possible that it's not the right moment for you to start downloading several large packages. Maybe you need to wait until there is more bandwidth available. If you run

apt-get upgrade -s

then nothing will actually happen- the upgrade will only be simulated. If there is too much information on the screen, then you can try

apt-get upgrade -s|more

. If it looks fine, then you run the above command again, taking away the -s

On the US keyboard, the so-called pipe symbol, | is found immediately to the left of the BACKSPACE key. Use the SHIFT key to type the pipe symbol.

8.9.3. Overview of Installed Packages

You can get an overview of installed packages using the command

dpkg -l|more

. Be aware that the first two letters indicate the status of the package; "ii" means that it is fully installed.

8.9.4. Finding the Name of a Specific Package

If you don't remember the name of a package, you can do a search of the database with the command

apt-cache search <packagename>

. If there is too much text on the screen, then you can try

apt-cache search <packagename>|more

The two symbols < and > must not be used. They are only used in this example.

8.9.5. Showing Available Information about a Package

The commands

apt-cache showpkg <packagename>

and

apt-cache policy <packagename>

will give you detailed info about the packacge.

8.9.6. Installing a Package

When you have found the package you want, install it with the command

apt-get install <packagename>

If you want to see what will happen when you install it, you can first run a simulation with the command

apt-get install <packagename> -s

8.9.7. Removing an Installed Package

To find the specific package that you want to remove, use the commands that were mentioned earlier for finding the name of the package.

When you know the name of the package, then you can remove it simply with the command

apt-get remove <packagename>

If you want to see what is going to happen when you remove the package, you can run a simulation first with the command

apt-get remove <packagename> -s

8.9.8. Installing one Specific Version of a Package

When you install a package with the command

apt-get install <packagename>

, the newest version will be automatically installed. Sometimes you don't want to install the newest version, just a little older version.

apt-get install <packagename>=older_versions_number

If you think that the older version of the backup module of Webmin is better, then you should run

apt-cache showpkg webmin-slbackup

to get an overview of available versions

tjener:~# apt-cache showpkg webmin-slbackup
Package: webmin-slbackup
Versions:
0.0.7-1(/var/lib/apt/lists/ftp.skolelinux.no_skolelinux_dists_woody_local_binary-i386_Packages)
(/var/lib/apt/lists/ftp.skolelinux.no_skolelinux_dists_woody-test_local_binary-i386_Packages)
(/var/lib/dpkg/status)
0.0.6-1(/var/lib/apt/lists/ftp.skolelinux.no_skolelinux_dists_woody-test_local_binary-i386_Packages)

Reverse Depends:
  education-main-server,webmin-slbackup
  task-skolelinux-server,webmin-slbackup
Dependencies:
0.0.7-1 - webmin (0 (null)) perl (0 (null)) libcgi-application-perl (0 (null)) 
libhtml-template-perl (0 (null)) libexpect-perl (2 1.15) slbackup (2 0.0.5-1)
0.0.6-1 - webmin (0 (null)) perl (0 (null)) libcgi-application-perl (0 (null)) 
libhtml-template-perl (0 (null)) libexpect-perl (2 1.15) slbackup (2 0.0.5-1)
Provides:
0.0.7-1 -
0.0.6-1 -
Reverse Provides:

Here you can see that there are two versions available: 0.0.6-1 and 0.0.7-1.

If you want to install version 0.0.6-1, you can do that with the command

apt-get install webmin-slbackup=0.0.6-1

8.9.9. Installing a Package with the Help of dpkg

Sometimes you want to manually download a package from somewhere, such as from Opera's web page. Then you get a so-called .deb-package in your own home directory. You can install it by using the command

dpkg -i <>

. If you first want to do a simulation, run the command

dpkg --no-act -i <packagename>

8.9.10. Searching Through Files that were Installed by a Specific Package

Sometimes it's nice to know exactly which files came from a specific package. You can get that overview with the command

dpkg -L <packagename>

8.9.11. Finding Which Package a File Came From

If you want to know which package a specific package came from, the command

dpkg -S <filename>

will help you find out.

8.9.12. Making Your Own Local Mirror for Deb-Packages

There are some packages which I often install, as well as some packages that I wish I didn't have to download from the Internet every time. Even if the commandapt-get makes it easier to install packages from the Internet, unfortunately apt-get won't increase the speed of my Internet connection. However, I can use apt-get to make my own mirror of the packages that I have downloaded. That way, in the future when I want to install these packages, the command apt-get will fetch the packages that I have already downloaded. This goes more quickly.

mkdir /var/www/dpkg
cp /var/cache/apt/archives/*.deb /var/www/dpkg
cd /var/www/
dpkg-scanpackages dpkg /dev/null | gzip -9c > dpkg/Packages.gz

After that, a new line in the file /etc/apt/sources.list must be added to

deb file:///var/www dpkg/
Then you must, as usual, run the command apt-get update in order to update your package database.