The Power of Apt

Apt, advanced packaging tool is a package management tool for Debian based systems. I have been using Ubuntu for more than 2 years and have become a great fan of apt. For those of you who know apt only as apt-get install/remove, are missing out on a lot of features provided by apt. This is a small article about some of those features.

Apt is not just about installing and removing softwares. It can be used for a lot of other purposes say, looking for some software, getting some info about a specific software, simulating an installation or removal of any software and a lot more. Following are some of the features of apt that most of us are not aware of.

Installing and removing software in a single command

If you are using apt-get install command then you can add a '-' at the end of any package to remove it.

[shredder12]$ apt-get install amarok exaile-

This will install amarok and remove exaile.

Similarly, if you are using apt-get remove then you can add a '+' at the end of the package name to install it.

[shredder12]$ apt-get remove exaile amarok+

This will do the same, remove exaile and install amarok.

Upgrading to a new release from a CD

First of all we need to  add the CD to the sources.list file. We can do this using apt-cdrom

[shredder12]$ apt-cdrom add

or, we can mention the CD mount directory using -d argument.

[shredder12]$ apt-cdrom -d /media/cdrom/ add

after that run the dist-upgrade(before that always remember to run an update in order to resynchronize the package index files with their sources)

[shredder12]$ apt-get update

[shredder12]$ apt-get dist-upgrade

Search for softwares

If you are looking for a software that does something but you don't know its name then you can use apt to search for that software using the keywords provided by you.

Consider this example, if you want a list of all the pidgin plugins available in the repos you can use apt-cache to search it. Use the following command

[shredder12]$ apt-cache search pidgin | grep plugin

And you will see a result similar to following.

Getting Details about a package

The search result above will output the result of the related searches with a small description of each software. If you want detailed info about any of them, use the following command

[shredder12]$ apt-cache show pidgin

To find out which package does a file belongs to

If you know about some file associated with a package and you don't know the name of the package then you can use apt-file.

[shredder12]$ apt-file search filename

apt-file maintains a database of packages and their associated files which needs to be updated. You can do it manually by

[shredder12]$ apt-file update

Completely remove a package(including configuration files)

The regular apt-get remove won't remove the configuration files associated with the package. In order to remove them too purge argument is used.

[shredder12]$ apt-get remove --purge nautilus

This will get rid of the configuration files as well.

Remove the unneeded .deb packages

Whenever you install a software its .deb file is saved in /var/cache/apt/archives/ folder. Over a period of time this cache may grow and occupy a lot of space, autoclean automatically removes debs which are not recent versions of that software. So, after running this command

[shredder12]$ apt-get autoclean

Your archive will have .deb files of most recent versions.

If you want to remove all of them, you can run this

[shredder12]$ apt-get clean

This will remove everything from the archives folder except the lock files.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <p> <br>
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.
  • Search Engines will index and follow ONLY links to allowed domains.

More information about formatting options

Mollom CAPTCHA (play audio CAPTCHA)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.