Install Software Packages and Dependencies for Debian


apt-get install [package]

The dkpg command is powerful, but after you use it for a while you'll quickly run into a problem when you try to install a package that has dependencies (otherwise known as "dependency hell"). In order to install package A, you also need to download and install packages B and C, but in order to install C you also need to download and install packages D and E, but in order to install E...aaaaaggh! You need apt!

The apt command and its accessories install, upgrade, and uninstall software packages. Best of all, apt automatically handles dependencies for you. For example, if you're trying to install package A from the example in the previous paragraph, apt downloads and installs A, B, and C for you. Later, if you decide that you no longer want A on your system, apt can uninstall it for you, along with B and C, as long as other software packages don't require them.

The apt command was originally developed for use on the Debian distribution as a front end to dpkg. It's now found on every Debian-based distributionwhich includes Debian itself, K/Ubuntu, Linspire, Xandros, and a whole host of othersand it's one of the features that make Debian so easy to use and powerful. Other, non-Debian distributions realized how great apt was, and eventually Connectiva ported apt to work with RPMs. (This chapter focuses on apt as it is used with Debian.)

Tip

For a good overview of apt as it is used with RPM-based distros, see my "A Very Apropos apt" in the October 2003 issue of Linux Magazine, available at www.linux-mag.com/2003-10/apt_01.html. In addition to that article, however, you should also check out http://apt.freshrpms.net for the latest in RPM repositories. Note that free registration is required to access Linux Magazine's content.


Let's say you want to install the awesome tool sshfs using apt. To do it, you go through the following process (and remember that these commands must be run as root):

# apt-get update Get:1 http://us.archive.ubuntu.com breezy  Release.gpg [189B] Get:2 http://archive.ubuntu.com breezy Release.gpg  [189B] Hit ftp://ftp.free.fr breezy/free Sources Hit ftp://ftp.free.fr breezy/non-free Sources Fetched 140kB in 1m4s (2176B/s) Reading package lists... Done [Results truncated for length] # apt-get install sshfs Reading package lists... Done Building dependency tree... Done The following extra packages will be installed:     fuse-utils libfuse2 The following NEW packages will be installed:     fuse-utils libfuse2 sshfs Need to get 96.9kB of archives. After unpacking 344kB of additional disk space  will be used. Do you want to continue [Y/n]? y Get:1 http://us.archive.ubuntu.com breezy/universe  sshfs 1.1-1 [19.3kB] ... Fetched 96.9kB in 10s (9615B/s) Reading package fields... Done Reading package status... Done Preconfiguring packages ... ... Selecting previously deselected package sshfs. Unpacking sshfs (from .../archives/sshfs_1.1- 1_i386.deb) ... Setting up sshfs (1.1-1) ... 


Let's go over what you just did because you actually ran two commands. apt-get update downloads a list of current software packages from apt serversknown as repositoriesthat are listed in your apt configuration file, found at /etc/apt/sources.list (if you want to see where your repositories are, run cat /etc/apt/sources.list). If you saw Get at the beginning of a line after running apt-get update, it means that apt saw that the list on the repository is newer, so it's downloading that particular list; Ign, on the other hand, means that the list on the repository and on your computer are in sync, so nothing is downloaded. By running apt-get update before you do anything else, you ensure that your list of packages is correct and up-to-date.

The command apt-get install sshfs retrieves the specified package, as well as any necessary dependencies (in this case, fuse-utils and libfuse2). After they're on your computer, apt (really dpkg acting at the behest of apt) installs all of the software for you. Keep in mind that you always use the package name, not the filename. In other words, use apt-get install sshfs, not apt-get install sshfs_1.1-1_i386.deb. As you saw, if apt does discover additional dependencies for the requested package, as it did for sshfs, you'll have to confirm that you want them installed before apt grabs them.

If you want to install more than one package at the same time, just list them all on the command line. For example, if you wanted to install sshfs and shfs-utils, you'd do the following:

# apt-get install sshfs shfs-utils 


Any dependencies for either sshfs or shfs-utils are discovered, and you are asked if you want to install them as well. Yes, it's that simple.

Tip

Don't know what sshfs is? Oh, but you should! Read my blog posting "Mount Remote Drives via SSH with SSHFS," which you can find on The Open Source Weblog at http://opensource.weblogsinc.com/2005/11/03/mount-remote-drives-via-ssh-with-sshfs/.




Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net