Package Management with APT : Ubuntu (all versions)

By | 2007/01/04

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.

apt 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

technorati tags:, , , ,

12 thoughts on “Package Management with APT : Ubuntu (all versions)

  1. Steve Kowalik

    aptitude moo, and aptitude -v moo (and so on) are great fun too. 🙂

  2. Pingback: Package Management with APT : Ubuntu (all versions) « Tuxicity’s source

  3. sharms

    It should be noted for apt-cache users that the –installed flag will not work as expected.

  4. Bradley Booms

    I believe apt-get does do a decent job of removing dependencies, you simply use autoremove instead of remove.

    ex.
    apt-get autoremove [package]
    instead of
    apt-get remove [package]

  5. Brad Johnson

    Also, if you run simply apt-get remove and there are unneeded dependancies, apt will notify you that apt-get autoremove will remove those as well … so it can be done after the fact as well.

  6. ubuntu

    very helpful thanks a mill

    salute

  7. Loye Young

    I cannot agree more strongly that apt-get should be deprecated, both because it’s in keeping with Debian practice and because it’s the Right Thing To Do (TM).

    The official Debian Reference states:
    aptitude is now the preferred text front end for APT, the Advanced Package Tool.
    . . . .
    Once you start using aptitude it is best to continue using it rather than alternative methods of installing packages; otherwise you lose the advantage of aptitude keeping track of which packages you have deliberately installed.
    See http://www.debian.org/doc/manuals/reference/ch-package.en.html.

    The following link contains a very good analysis of why everyone should use aptitude instead of apt-get, including its better handling of dependency issues. http://www.garfieldtech.com/blog/your-debian-aptitude.

    Happy Trails,

    Loye Young
    http://www.iycc.biz
    Laredo, Texas

  8. Pingback: Getting the source package with aptitude? : Ubuntu Tutorials : Dapper - Edgy - Feisty - Gutsy

  9. Pingback: The Linux Index » Christer Edwards: Getting the source package with aptitude?

  10. JosephTaiwo

    I use a Kubuntu OS that is not connected to the internet, all the packages i wish to download always have on or more dependencies which in turn depend on some other dependencies and the chain continues. is there any way i can download a package and all its dependencies without having to go through the stress (the Kubuntu system is not connected, i have to use some other system in my office to do the download)

  11. Jeremiah

    @JosephTaiwo:

    I wrote a web-app that you can use for this purpose, it’s available at http://packagedepends.homelinux.org:8080 if you want to use it.

    Alternatively, you could do what my tool does, which is “apt-get –build-dep -d packagename && aptitude download packagename”, which should give you the packages needed to install on your system. (assuming, at the moment, that you’re running hardy)

  12. coco

    aptitude safe-upgrade
    aptitude full-upgrade

Comments are closed.