| > |
I've found an excellent guide to apt on debian's webpage: you should check out the following:
In particular it details how to use some increadibly powerful tools such as auto-apt for automatically installing packages based on the files that a command needs (such as a ./configure: running auto-apt run ./configure will install all the packages that have the needed .h files for the configure script), netselect for automatically choosing the fastest debian mirror from a given list, apt-cache--an alternative to dpkg -l with better output, and some other great stuff.
Another great command I found out about lately is dlocate. It is a fast, powerful alternative to the dpkg -S and dpkg -L commands. One of the really cool things it can do is check all the md5 checksums of files in a package and compare them to the checksums the file had when the package was installed. This could be very useful in checking to see if you're system has been hacked. See the manpage for details.
One of the most brilliant aspects of the Debian GNU/Linux distribution is the package system. It is all based around the command "apt-get".
All of the packages that debian produces are available directly from the internet, and can be retrieved from any computer via http or ftp. Debian's package manager knows this: the smart thing is that they have arranged it so that it can download them automatically for you. It is even smart enough that when a package depends on another package, it tells you this and offers the option of downloading, installing, and configuring all the required packages for you. Installing something nasty like gnucash, which has a lot of library dependencies, is as easy as "apt-get install gnucash".
Debian has a policy of maintaining more than one distribution at once. For example, right now, debian has three linux distributions: "stable", "testing", and "unstable". The packages in stable are typically a version or two behind of the latest release, but are considered by the tough debian standards to be reliable, secure, and bug free. The stable distribution right now is version 2.2, which has the name "potato". There are about 4000 packages in potato.
The "testing" distribution is a collection of packages that are getting ready to become the next stable distribution. These are packages of software that has been in the distribution for a while. These are usually very nearly the latest release of the software. This is currently named woody, and contains around 5000 packages.
"Unstable" is the developers distribution. Whenever a debian developer downloads the updates from the software homepage and compiles it, it gets uploaded to the unstable distribution. The unstable distribution is also used for testing out new debian configuration tools and stuff. Software versions in unstable change on a daily basis, and the unstable distribution currently has more than 7000 packages.
The most important configuration file for apt is "/etc/apt/sources.list". This file tells the apt-get program where to download it's packages and package information from. A sample one may look like:
# See sources.list(5) for more information, especialy # Remember that you can only use http, ftp or file URIs # CDROMs are managed through the apt-cdrom tool. # Potato #deb ftp://ftp.us.debian.org/debian/ potato main non-free contrib #deb-src ftp://ftp.us.debian.org/debian/ potato main non-free contrib #deb http://non-us.debian.org/debian-non-US potato/non-US main contrib non-free #deb-src http://non-us.debian.org/debian-non-US potato/non-US main contrib non-free # Woody (testing) deb ftp://ftp.us.debian.org/debian/ woody main non-free contrib deb-src ftp://ftp.us.debian.org/debian/ woody main non-free contrib deb http://non-us.debian.org/debian-non-US woody/non-US main contrib non-free deb-src http://non-us.debian.org/debian-non-US woody/non-US main contrib non-free # Unstable #deb ftp://debian.crosslink.net/debian/ unstable main non-free contrib #deb-src ftp://debian.crosslink.net/debian/ unstable main non-free contrib #deb ftp://non-us.debian.org/debian-non-US unstable/non-US main contrib non-free #deb-src ftp://non-us.debian.org/debian-non-US unstable/non-US main contrib non-free
Here you can see that I have uncommented out only one distribution.
Debian usually only provides installation disks for the stable distribution. This is not a problem, though: you can just change which distribution you're using in your sources.list file, and start using packages from another distribution! It will update the packages it needs to (like libc) as it goes along. Things to be careful of: make sure you only pick one distribution at a time, and make sure you update the package manager after each time you change sources.list. The update is done by two commands:
apt-get update; dselect update
(Note: "apt-get update" updates apt-get's list of packages, and "dselect update" updates the package information database that the dpkg command uses.)
The nice thing is that 90% of the time, you can find a debian package for software, as long as you don't mind using unstable (which, despite it's name, is really actually quite stable--more so than any redhat distribution...). But that's not it: the beauty is that anyone can set up their own repository of debian packages, and share the packages they've made with the rest of the debian community! This is really what the whole linux thing is all about. Many people have in fact done this. (See my apt sources list below.)
Here's a list of debian package management commands that I use on a regular basis:
Install the software in the package named "foobar"
Remove all the files in the package foobar. This will not remove any packages that were installed automatically to satisfy dependencies: do a dpkg -p to figure out which packages foobar depends on, and apt-get remove them if you no longer need them. Note that this will not remove configuration files the package may have (the installer will tell you if it leaves the configuration files): add the "--purge" flag or use dpkg -P to do this.
Download the debian source tarball for the program foobar. Note how easy it is to build a debian package from a debian source: just go to the source directory, and use the command ./debian/rules binary.
I just learned about this one six monthes ago. This one is particularly brilliant! This will install all the packages (ie. compilation tools, shared libraries, library header files) that you will need to compile the program foobar. Wow.
List all the packages that are installed on your system. You probably want to pipe this into less or more.
List all of the packages in the dpkg database that contain the word "foobar". The slashes protect the stars from the shell. You could also use quotes. Note that this will search the entire list of packages in the distribution you're using, not just the ones you've installed. This is useful for searching for a package for a piece of software when you not sure of the exact package name.
This will also show you the status of a package: if it's installed, if it was installed then removed, if it was removed but not purged, etc.
Print information about the software in package foobar. This will include the size, the dependencies, any packages that foobar recommends, a description of what foobar is and does, and more.
List all of the files that are installed with package foobar.
Search in the file listings of all the packages installed on the system for a file or directory name that contains "foo.sh". Say you've got a file "foo" and you wanted to know which package it belongs to, you can use dpkg -S to find out.
Remove the package foobar, and purge any configuration files it may have.
There are many more flags for the dpkg command. Consult the man page for more information.
Here's a link to an excellent APT and dpkg quick reference sheet.
Another great resource is the Debian package page. This has a web interface that can search the package names in all of the distributions. You can also search the entire contents of all the distributions for a file or directory name.
This is particularly useful: for example, let's say you're compiling program x (which say doesn't have a debian package), but it gives you a message "command xyz not found". Maybe it's not obvious which debian package will contain command xyz. Just go to the debian package page, enter "xyz" into the distribution content search, pick your distribution, and if there's a debian package, "voila!", you've got the package name. It's pretty sweet.
Here's some of the useful apt sources I've found:
# Java 1.2 deb ftp://www.ibiblio.org/pub/Linux/devel/lang/java/blackdown.org/debian woody non-free
The blackdown.org java packages, mirrored on ibililo.org (formerly metalab, which was formerly sunsite). This may now be in testing or unstable.
# Daily wine CVS deb http://gluck.debian.org/%7Eandreas/debian wine main deb-src http://gluck.debian.org/%7Eandreas/debian wine main
The latest wine cvs packages built for debian.
# OMS DVD Player deb http://linuxvideo.org/oms/data/debian/ ./
The OMS DVD player for linux.
If you've found any apt sources you find useful, I'd love to know about them: email me and I'll add them to my list.