Package Management with APT
If you’ve read any of my previous posts you know they all take advantage of APT to install or upgrade packages. If you’ve spent more than a few hours using Ubuntu you’ve probably taken advantage of APT. Anytime you add, remove or upgrade part of your system you’re using APT. I thought I would take a minute today to explain a few more features of APT that you might not be familiar with.
First of all you might have noticed that all of my tutorials use the command aptitude instead of apt-get. The reason for this, from my understanding (and perhaps some of you can address this in a bit more detail) that aptitude handles dependencies better than apt-get. For example, if you install package X which also has dependencies Y and Z either of these (apt-get or aptitude) will bring in the dependencies, but only aptitude will remove those unneeded dependencies when you later decide to remove package X.
Outside of this difference between the two commands the options are almost all the same. I thought I would go over these in a little more detail for those of you that aren’t familiar.
update – this option used with aptitude or apt-get will retrieve the latest versions of packages from the update servers. You should check for updates periodically (normally your system should check automagically from time to time)
search [keyword] – this option will allow you to search for packages by name or description. Do you want to find a package that offers feature [keyword] or [keyword]? Simply use aptitude search [keyword] (or with apt-get use apt-cache search [keyword]) and a list of packages will be retrieved matching your search.
show [package] – this option will show you more detail about the package. File sizes, extended descriptions, dependencies and maintainer information. This is useful when you want to know more about your package. As above if you’re using apt-get the command would be apt-cache show [package].
install [package] – this option is pretty straight forward. If you want to install [package] use the command and your package will be retrieved and installed for you. If you’ve ever installed anything from the command line or used any of my previous tutorials you’ve definitely used this option.
remove / remove –purge [package] – this option will let you remove a package that you had previously installed. Using the remove option your system will uninstall whatever package you want (see above on using aptitude for dependency removal). Using the –purge option will also remove any configuration files that your program had included. If you know you are never using the program again and can safely purge any trace of it, you can use the –purge option. If you might be back (it happens) the config files might come in handy later.
upgrade – this option will allow you to upgrade your system. After running update (see above) using the upgrade command will get your system up to date on anything new waiting on the central package repositories. You should regularly run update and upgrade to keep your system up to date.
dist-upgrade – this option will do a complete upgrade of your system. Often a package will be updated but the new version also depends on additional packages. To make sure you are completely updated you’ll want to also include this in combination with upgrade. A complete set of upgrade steps would be to use update followed by upgrade and then dist-upgrade.
autoclean – this option cleans your system from previous upgrades. The APT system will download the latest package when it upgrades your system. If you have upgraded a package two or three times since originally installing you might then have three versions of that package in your system cache. Using autoclean tells your system to remove the previous, now unneeded packages. This is also a good idea after running upgrade and dist-upgrade.
These might seem like a lot to handle or remember. It really isn’t much once you’ve gone through the steps once or twice. You might be interested in seeing a previous post to automate the updating. One that will update, upgrade, dist-upgrade, and autoclean your system using one simple command.
Ooh, and for a little bit of fun try this: apt-get moo