Debian Package Management and Tools http://www.debian.org/doc/manuals/reference/ch-package.en.html -------------------------------------------------------------------------------- Quick Notes: apt-get install apt-file #install apt-file apt-file update #update apt-file database apt-cache search <pattern> #search for installed package apt-file search <filename> #search all avail packages apt-file list <package> #list contents of a package apt-get update ; apt-get upgrade #upgrade packages (not distro) apt-get remove <package> #remove package dpkg -i <package.deb> #install deb package dpkg -r <package> #remove installed package dpkg --purge <package> #remove config files (or -P) dpkg -l [pattern] #list installed packages dpkg -L <package> #list file for package dpkg -S|--search <file> #find package owning file (-S) dpkg -s|--status <package-name> #display package status details dpkg -x <package.deb> <folder> #extract package contents -------------------------------------------------------------------------------- To install a .deb file, become root and use the command: dpkg -i filename.deb Dpkg can also be used to: dpkg –unpack unpacks the file but does not install it dpkg –configure presents whatever configuration options are available for the package dpkg –remove removes a package Some of the package manipulation commands are actually carried out by an application called dpkg-deb. In those cases, dpkg just acts as a front end to dpkg-deb and passes the commands to it. dpkg-deb can also be used to manipulate .deb files. Some of the more useful commands of dpkg-deb are: dpkg-deb –show filename.deb -------------------------------------------------------------------------------- Main package management tools dpkg – Debian package file installer apt-get – Command line front end for APT aptitude – Advanced text and command line front end for APT synaptic – Gtk GUI front end for APT dselect – Menu-driven package manager tasksel – Task installer These tools aren't all alternatives to one another. For example, dselect uses both APT and dpkg. APT uses /var/lib/apt/lists/* for tracking available packages while dpkg uses /var/lib/dpkg/available. If you have installed packages using aptitude or other APT front ends and you want to use dselect to install packages then the first thing you should do is update /var/lib/dpkg/available by selecting [U]pdate from dselect's menu (or by running "dselect update"). Convenience tools dpkg-reconfigure - reconfigure an already installed package (if it uses debconf) dpkg-source - manage source package file dpkg-buildpackage - automate the building of a package file apt-cache - check package archive in local cache -------------------------------------------------------------------------------- Debian Package Management Package management in the Debian system is handled through a program called APT. Package management is largely handled through releases. There are three branches of Debian releases at any given time, known as stable (Sarge), testing (Etch), and unstable (Sid). The release of a Debian system is determined by the file /etc/apt/sources.list. This file lists the APT sources from which packages will be downloaded and installed. The following example is for a system running the Sarge release: /etc/apt/sources.list: deb ftp://mirrors.kernel.org/debian sarge main deb http://non-us.debian.org/debian-non-US sarge/non-US main deb http://security.debian.org/ sarge/updates main This file specifies the Debian mirror mirrors.kernel.org as the APT repository to use. This mirror offers the most throughput and highest connectivity rates to the ServePath network. To update all installed packages, # apt-get update && apt-get dist-upgrade This will update any Debian system with the latest packages on the APT repository specified in /etc/apt/sources.list, and intelligently update all installed packages, as well as any dependencies that may arise. To remove an installed package, first execute the following to find the package name, # dpkg –l Once the package name has been retrieved, execute the below to uninstall, # apt-get remove <package-name> To install a package, # apt-get install <package-name> To find out what package a program belongs to, # apt-get update && apt-cache search <program-name> Some of the above may require a pager such as more or less to effectively view the results. If you want to install a package, and you can't find out what it is called by searching with apt-cache, but know the filename of the program itself, or some other filename that belongs to the package, then you can use apt-file to find the package name. This is done like this: $ apt-file search filename It works just like dpkg -S, but will also show you uninstalled packages that contain the file. You can also list the contents of a package, by running: $ apt-file list packagename apt-file keeps a database of which files all packages contain, just like auto-apt does and it needs to be up-to-date. This is done by running: # apt-file update By default, apt-file uses the same database auto-apt is using. If apt-file is not installed, do the following: # apt-get install apt-file # apt-file update Using dpkg to find the package a file belongs to: # dpkg -S stdio.h -or- # dpkg -S /usr/include/stdio.h To find out the names of packages installed on your system, which is useful, for example, if you plan to clean up your hard drive, you can run: # dpkg -l | grep mozilla The problem with the above command is that it can "break" the package name. In the example above, the full name of the package is mozilla-browser. To fix this, you can use the COLUMNS environment variable this way: $ COLUMNS=132 dpkg -l | grep mozilla ii mozilla-browser 0.9.6-7 Mozilla Web Browser - core and browser -------------------------------------------------------------------------------- How to install packages "on demand" You're compiling a program and, all of a sudden, boom! There's an error because it needs a .h file you don't have. The program auto-apt can save you from such scenarios. It asks you to install packages if they're needed, stopping the relevant process and continuing once the package is installed. What you do, basically, is run: # auto-apt run command Where `command' is the command to be executed that may need some unavailable file. For example: # auto-apt run ./configure It will then ask to install the needed packages and call apt-get automatically. If you're running X, a graphical interface will replace the default text interface. Auto-apt keeps databases which need to be kept up-to-date in order for it to be effective. This is achieved by calling the commands: auto-apt update, auto-apt updatedb and auto-apt update-local