5 Simple APT Tricks for Debian and Ubuntu

    Here are five simple tricks for APT, the Advanced Packaging Tool used on Debian and Debian-based distributions like Ubuntu.

    View all the packages installed on a system

    The easiest way to do it is:

    dpkg --get-selections

    It does not require to be root, and will display all the packages installed via APT. For example, the first lines may look something like:
    $ dpkg --get-selections | head
    acetoneiso2 install
    acidrip install
    acpi-support-base install
    acpid install
    adduser install
    akregator install
    alien install
    alsa-base install
    alsa-oss install
    alsa-utils install
    You can also put the entire list in a text file by redirecting the output, like this:

    dpkg --get-selections > installed_packages.txt

    Then read this file with a text editor or using less installed_packages.txt.

    List files which get installed by a package
    -L is a handy parameter to dpkg which will show you what files a package will install.

    dpkg -L package_name

    For example:

    dpkg -L amarok

    Will show all the files which are going to be installed by package amarok. You don't have to be root to run it.

    Upgrade your system using a one-liner
    Type as root:

    apt-get update && apt-get dist-upgrade

    This command will update your list of packages, and if its return status is successful, it will proceed to the next command, apt-get dist-upgrade, which will upgrade all of your packages and will install new dependencies if needed. Use dist-upgrade when you want all of your packages to be installed, and no package left as being kept back.

    Install the dependencies of an application
    Sometimes you need to compile from source a newer version of an application which is already included in the repositories. For example, to install the development libraries for BasKet, you would run as root:

    apt-get build-dep basket

    And then you can proceed to compile your application. Note that sometimes newer versions of applications may depend on newer libraries or other packages than you do not have in the repositories, so this won't always work.

    Remove unused package files
    When you install software using APT, the DEB packages are kept inside the /var/cache/apt/archives directory. In time, the size of it could get very large. To see what is the size of that directory, you can use:
    $ du -h /var/cache/apt/archives/
    4.0K /var/cache/apt/archives/partial
    956M /var/cache/apt/archives/
    In order to clean up all these packages you can use, as root:

    apt-get clean

    This command will remove all the packages except files which are locked. There is another command, apt-get autoclean, which will remove all the packages which are no longer available in the repository (older versions of packages which can't be downloaded any more).Source URL: http://ashesgarrett.blogspot.com/2008/10/5-simple-apt-tricks-for-debian-and.html
    Visit ashes garrett for Daily Updated Hairstyles Collection

Blog Archive