by pbharris
Created Novemember 6, 2002.

(Transferred from Wiki by Peter)

Debian is regard by many people to be the best and purest of all linux distributions, one of its strengths is its excellent package management systems combined with apt-get. This cheat sheet will give some of the common commands used by Debian and other distributions based on Debian. Debian packages are often called debs because they have a .dep suffix. On with the cheat sheet! First dpkg then apt-get


If I am interested in only one package or I want some information I use dpkg
dpkg -i packagename.deb
- this installs a packge named packagename, e.g. dpkg -i zsh_4.0.4-33_i386.deb.
dpkg -s packagename
- This will return the status on a package, e.g. dpkg -s fvwm, note the suffix .deb is not used with this command.

  dpkg -L packagename
- Lists all the files in package, e.g. dpkg -L zsh will list all the files installed with the package we installed in the first step. Again, the suffix .deb is not used.
  dpkg -S filename
- This will tell the user what package the file filename belongs too. e.g. dpkg -S init-restart.hook will let the user know that the file init-restart.hook belongs to the package fvwm. The full path can be given,e.g. dpkg -S /etc/X11/fvwm/init-restart.hook , but it is not needed. If the full filename is not known a partial name can be given also. e.g. dpkg -S restart would give the results with all packages that have a file that has restart in the name.
  dpkg -r packagename
-This will remove the package from the system. e.g. dpkg -r zsh will remove the package installed at the start of this cheat sheet.

Now for apt-get!

apt-get install packagename
- This is a common command that will install the package packagename, if it needs to it will also resove dependencies and install them all. There is no need to say add the veriosn information or the .deb to this and doinng so will result in an error. An example would be: apt-get install fvwm2
apt-get source packagename
This downloads the source code of the package. e.g. apt-get source fvwm2
  apt-get update
This will update the list of packages available to be installed. It does not actually update any package!! This takes no arguements, e.g. apt-get update kernel will not update your kernel.
  apt-get upgrade
Like apt-get update this command does not take any extra arguement, it will however upgrade all the packages on you machine that are out of date.
apt-get clean
This will remove the packaes that have been downloaded which are kept in /var/cache/apt/archives. This saves disk space and if you have apt-get upgrade run automatically this should be done on a regular basis.
Those are the main apt-get commands I use. For apt-get you do need a sources-list - Mine is listed below, this is the file /etc/apt/sources.list

deb woody main contrib
deb testing main non-free contrib
deb-src testing main non-free contrib
deb testing/non-US main contrib non-free
deb-src testing/non-US main contrib non-free

deb stable/updates main contrib non-free