apt-get bash foo
November 13th, 2007Apt-get returns the error: “E: Dynamic MMap ran out of room”
This is caused because the cache is too small to handle all of the packages in the flavour of Debian that you are using. The fix for this is trivial, just add the following line into /etc/apt/apt.conf:
APT::Cache-Limit 12582912;
If that file does not exist, create it. If you still get the same error, increase the value.
How do I list all the packages I have installed?
The easy way is to do:
dpkg -l
But this has issues since some of the package names are truncated due to the column width. A more accurate way is to do:
COLUMNS=200 dpkg -l
You can further define that command by showing only those packages which are installed:
COLUMNS=200 dpkg -l | awk '/^ii/ {print $2}'
For additional information about this, there’s some excellent examples on the ManagingPackages/Apt page.
Reinstall all packages
Sometimes there is a need to reinstall all packages currently on your system. This can be achieved by:
COLUMNS=200 dpkg -l | awk '/^ii/ {print $2}' | xargs apt-get --reinstall install
Note the use of the environment variable ‘COLUMNS’ which ensures that the package names are not truncated on output. A value of 200 is usually sufficient for those packages that have long names.
Removing leftover files after removed packages
If you remove a package without purging it, configuration files related to that package are left behind. If you want to remove these leftover files, you can run:
COLUMNS=200 dpkg -l | awk '/^rc/ {print $2}' | xargs dpkg --purge
Removing dependencies of packages no longer required
This is often related to meta-packages which are empty packages depending on a large number of packages so that a suite of applications can be installed (’build-essential’ and ‘gnome-desktop-environment’ are such examples). Removing these meta-packages is perfectly valid, and will leave the dependencies behind (although aptitude may well remove them). If you wanted to remove the dependencies as well; and you are using apt-get; you can use debfoster and deborphan. Deborphan was originally written to handle removing libraries and so to get it to recognise packages that are not libraries, run:
deborphan --all-packages
Installing a package and ignoring its dependencies
I’m often asked “How do I install a package and not install its dependencies”. The answer is that you don’t. If you do, you can be expected to sort out the mess yourself since you must have had a good enough reason to ignore it in the first place. If you’re still sure you know that you want to disregard the package handling, read dpkg --force-help, although until you fix the dependencies manually, you won’t be able to use apt-get. That said, there might be a valid reason whereby you need to fool the system into thinking you have a package installed. In such instances you should use equivs, but this not meant as a replacement to fix dependencies.
How do I install a .deb file?
dpkg -i ./the_file.deb
How do I extract files in a .deb file?
dpkg -x ./file.deb /some/directory
Can I clone an existing Debian install on another machine?
Sure, here’s how. On the machine that has all the packages installed that you want replicated to another machine, as root, run the command:
dpkg --get-selections > ./selectionfile
After the base install has finished on the other machine, copy the “selectionfile” to this machine and run the command:
dpkg --set-selections < ./selectionfile && apt-get dselect-upgrade
This will then install all of the packages from the list specified.
How do I stop packages being upgraded when I update my system
By default when you install packages on your system, the next time you go to upgrade it those packages will be updated. There are times when this is not desirable (such as wanting to retain a copy of an installed package you had made yourself). To stop a package from being updated, you can use:
echo "packagename hold" | dpkg --set-selections
How do I upgrade packages that are on hold?
In addition to the answer above, the reverse of that is:
echo "packagename install" | dpkg --set-selections
If you want to upgrade all held packages regardless, you can tell apt-get to do so:
apt-get --ignore-hold upgrade
Although this does not affect the state of a package afterwards, it just causes apt to conveniently forget about the status of all held packages for the initial update. To make the change to a package’s status permenant, you’ll want to use the first example.
Note also that putting packages on hold this way means that they will be ignored by aptitude, should you be using that. This is a known bug. You have been warned.
I installed unstable by mistake. How do I downgrade?
You don’t. Short answer, eh? The reason being that to do so is a pain in the arse. It’s possible, but unless you like to play ‘pinning’ games with apt, the canonical answer is to reinstall, this time using the correct flavour of Debian. For the curious, a good reference is here: http://people.debian.org/~osamu/downgrade.html
An alternative is to amend your source.list file to use testing sources, and wait a long time before upgrading. After a few months, the packages in testing will be of a newer version that those that were in unstable when you installed it. Running the usual apt-get update && apt-get dist-upgrade combination will install the packages that have newer versions in testing. Note though that there’s no guarantee that the packages in testing will be newer that those that were in unstable. I refer to this technique as “sidewaysgrading”.
I want to install a newer version of a package not available in Stable
Since the packages that stable contains is set in stone, the version that you install them at will remain at that version. This can sometimes be problematic, since you may well want a newer version of a package installed. This is where backports are handy. There are two main sites for these:
http://www.backports.org
http://apt-get.org
If you cannot find the package you want in either of these you can always grab the source package and build it yourself. The following achieves that:
Add a deb-src line for unstable in /etc/apt/sources.list, something like:
deb-src http://mirror.ox.ac.uk/debian/ unstable main apt-get update apt-get build-dep packagename apt-get -b source packagename
This will then pull the dependencies of the package you’re after and build it against them for inclusion on your stable box. Note that this is not always a good idea, and you can break your system if the dependencies have changed significantly.
Debian doesn’t use an /etc/rc.{boot,local} file?
/etc/rc.local or /etc/rc.boot are the boot scripts used by BSD / Redhat / SuSE. It’s lazy, and you should use other means under Debian. If you simply try and create an /etc/rc.boot file under Debian, it won’t get read. The proper way of doing it is to use the sysvinit method via the command update-rc.d (see /RunLevels for more information). Although this can sometimes be daunting. If you simply wanted to have a script run at startup, you can create an /etc/rc.boot directory, and place your script(s) inside that directory. You should ensure that the file permissions are set to 0755; both on the directory, and the scripts contained therein.
I can’t compile anything, what do I need to install?
apt-get install build-essential
What’s the difference between an upgrade and a dist-upgrade?
Upgrading software on your machine involves installing newer version of packages that are available. Like many people this will involve the use of the internet, whereby packages are downloaded from mirror sites. If you’re using Debian Stable, then the only new releases you’ll get are security ones. If you’re not, then these packages will be downloaded as needed.
An upgrade (via apt-get upgrade for example) will only install those packages which do not depend on packages not yet installed on your system. So for example, let’s say that there was an upgraded package “cowsay” that you had installed on your system. If that package’s depenencies are already installed on your system then it will be installed without fuss. If the “cowsay” package dependencies however, showed that there were some packages not installed on your system it would be “held back”. This is why when you upgrade you sometimes see many packages held back.
A dist-upgrade however will upgrade all packages regardless of whether the dependencies are installed already or not. Generally this is the option that most people use when upgrading their system.
When I do an update, I get lots of packages held back, why?
See the answer above. What you want to do is:
apt-get -u dist-upgrade
Do I have to do anything special when a new stable release is made?
That depends on what you have in your sources.list file. Depending on how you installed your system you may find that you have a line that looks like:
deb http://mirror.ox.ac.uk/debian/ stable main
If you’re using the word “stable” as opposed to the nickname of the distribution (e.g. “Woody” or “Sarge”) then a dist-upgrade when the stable release is made will upgrade you to the new release. If, however, you are using the nickname, liek “Woody” or “Sarge” on your deb lines, then you will have to ensure that you change that to the nickname of the new stable release as and when you want to upgrade to it.
So, using the nicknames gives you more control over when and whether you upgrade to a Debian release, but requires a little more work when you do want to upgrade. Using the release type (e.g. stable) means that you have less to do to upgrade, but you will upgrade to the new version when it is released.
Note that when a new stable release is made, the security releases for the old version it will remain usually for up to six months post Sarge’s release. But by that time, you’d have upgraded… For more information see the /DebianReleaseProcess page.
Debian no longer asks me configuration questions when I install new packages
First of all, this could simply be because the package in question doesn’t have any questions to ask you. However if you know that it does, and you’re not seeing any, run the following:
dpkg-reconfigure debconf
and select “dialog”.
How do I re-run the configure screen for a specific package?
Debian’s “configuration” program is handled by “debconf”. This is what certain packages use when asking questions. To run it for packages you can do:
dpkg-reconfigure <packagename>
If you are unsure of the package name, you can install and use the package configure_debian. In this way, you can then run the command: configure_debian and use the menu-based navigation screen to select the package(s) that you want to reconfigure.
My keymap is messed up at the console. How do I fix this?
dpkg-reconfigure console-data


