See also: permalink.de/tino/aptitude

Mastering Debian

The basic configuration: APT

Now you have a minimal running system.
It's plain and you want to setup your system.
To do this, you need to know the Debian way.
That's apt.

To use apt efficiently you have to remember zillions of different commands. In future, I want to replace it all by a single, friendly frontend called hx, the "hilbix console" (it will be based on CGI).

Commands

vi /etc/apt/sources.list
apt-get update
apt-get upgrade
apt-get install package
apt-get autoclean

dselect
apt-cache search whatever
apt-cache depends package
apt-cache show package

dpkg-query -l
dpkg-query -W package
dpkg-query -L package
dpkg-query -S /path/file
dpkg-reconfigure package

dpkg --get-selections
echo package hold | dpkg --set-selections

dpkg --get-selections | grep deinstall
dpkg -P package...
Find where something hides (what's the difference to dpkg-query, please?):
dpkg -S `which exec`
dpkg -L package
Or in one (shoot them. Shoot them quickly, please, but shoot them!):
dpkg -L $(dpkg -S $(which exec) | cut -d: -f1)

/etc/apt/sources.list

This file probably will look like below.
Some docs say to use testing. That's not what you want, so the third word definitively is "sarge". Also you want "main contrib non-free". And you add the deb-src lines, too. Additionally don't forget to add the non-US packages. You want them.

At the end add additional distribution packages.
Add your debian server with your own distribution packages there.
deb http://ftp.uni-erlangen.de/pub/Linux/debian/ stable main contrib non-free
deb-src http://ftp.uni-erlangen.de/pub/Linux/debian/ stable main contrib non-free
deb http://security.debian.org/ stable/updates main contrib non-free

non-US myths

If you ever see a reference to non-US this is for Debian Woody and before. Since Sarge you do not need them. Since Lenny non-US entries do harm.

If you are curious, have a look into the Archive.

Apt settings

Put your changed apt settings into a file named /etc/apt/apt.conf
If you are puzzled what you can put there, see
zless /usr/share/doc/apt/examples/configure-index.gz

The long syntax looks like
Acquire
  {
    http 
      {
        Proxy "http://127.0.0.1:3128";
      }
    Timeout 60;
  }

The short syntax looks like:
Acquire::http::Proxy "http://127.0.0.1:3128";
Acquire::Timeout 60;

I do like more the latter, because this one is more easy to handle with scripts.

Additional Apt Settings

Increase the Apt limit (often needed when you want to upgrade, so you have a lot of sources):

/etc/apt/apt.conf
Apt::Cache-Limit "16384000";
you need this if you see something like
Reading package lists... Error!
E: Dynamic MMap ran out of room
E: Error occurred while processing unixodbc-dev (NewVersion1)
E: Problem with MergeList /var/lib/apt/lists/ftp.de.debian.org_debian_dists_stable_main_binary-i386_Packages
E: The package lists or status file could not be parsed or opened.

Backports

See backports.org/dokuwiki/doku.php?id=instructions

To install from backports, use
aptitude install <package>
because "apt" alone might not work.
Aptitude explains you what to upgrade, if it comes to resolve of dependencies within backports.

Remove non-US!

Remove all traces of non-US from sources, as those trigger a signature problem. non-US is obsolete now!
deb http://ftp.uni-erlangen.de/pub/Linux/debian/ stable/non-US main contrib non-free
deb-src http://ftp.uni-erlangen.de/pub/Linux/debian/ stable/non-US  main contrib non-free

Following text is no more recommended
Add syscp, you want to hand this to your customers nearly for sure.
deb http://debian.syscp.de/ etch/

APT helpers

debfoster and deborphan

Handle orphaned packages (those, which are installed but no more needed):

apt-get install debfoster deborphan
debfoster
apt-get purge `deborphan`

debsums

If you think your harddrive corrupted some files, try debsum

apt-get install debsums
debsums -ac

The problem with this script is, that it always starts from the beginning. And it can only check for archives, it has listed locally (often the base packages from install are missing). I currently have no solution for this.

However it is better than nothing.

aptitude

Well, you needed some things from testing or unstable before, but now the next release is out and you want to revert back to stable?

Aptitude is your friend. Like this:

aptitude -t stable dist-upgrade

Use this command wisely. It often needs several steps, as it does not advice you to downgrade in one step. This is OK.

Sometimes it is clever to uninstall things first and re-install them later. If this helps, try this way. And keep your apt-preferences correctly, such that it stays where it is if it can:

Example /etc/apt/preferences for Lenny which once was Etch:
Explanation: See http://www.argon.org/~roderick/apt-pinning.html
Package: *
Pin: release o=Debian,a=lenny
Pin-Priority: 900

Package: *
Pin: release o=Debian,a=etch
Pin-Priority: 800

Package: *
Pin: release o=Debian,a=testing
Pin-Priority: 400

Package: *
Pin: release o=Debian,a=unstable
Pin-Priority: 300

auto-apt

apt-get install auto-apt
auto-apt update
auto-apt updatedb
auto-apt update-local

Run something and find out which packages it needs:
auto-apt run COMMAND

apt-file

Find the package if you know the file name:
apt-get install apt-file
apt-file update
apt-file search FILENAME
apt-file list PACKAGE

apt-show-versions

Find which version a package has. This is important after you have upgraded something to find broken/old packages (those with no security patches!):
apt-get install apt-show-versions