Jan
27
2011

10 things you didnt know about ‘apt’

If you are into the world of Linux or thinking of trying it out, you will most probably stumble upon apt. Due to the increase trend of people shifting to Debian distribution, apt now has become a must know tool.

In fact, apt-get will make your life so easy in Linux that you will stop worrying about how to install and remove software on the Debian GNU/Linux distributions.

So what’s apt?
APT or Advanced Package Tool is basically a Debian package management utility that works with core libraries to handle the installation and removal of software on the Debian GNU/Linux distribution and its variants.

In simple words, if you need to install , remove and update packages apt is the perfect tool for you.

1. Installing packages

Default use,

$ apt-get install < package-name >

e.g. $ apt-get install vlc

To choose a particular version,

$ apt-get install < package-name=1.1 >

For source packages,

$ apt-get source < package-name >

To compile the source packages after downloading them,

$ apt-get source -b <package-name>

2. Re-installing  packages

$ apt-get –reinstall install < package-name >

3. Removing packages

$ apt-get remove < package-name > (Remember : this will not remove the configuration files)

for complete removal ( i.e. with configuration file )

$ apt-get –purge remove  < package-name >

4. Upgrading  packages

$ apt-get upgrade package-name

Upgrade all the packages which needs an upgrade,

$ apt-get -u upgrade

To add a CD to the source list

$apt-get cdrom

To upgrade the whole distribution to a new version,

$ apt-get dist-upgrade

5. Searching for packages

$ apt-cache search package-name

To list all the dependencies of a package and all the other packages that can fulfill that dependency,

$apt-cache depends package-name

6. Checking installed versions or decide the source

$apt-cache policy <package-name >

7. Show full description of a package

$apt-cache show package

8. Check for any broken dependencies

$ apt-get check

9. Clear the cached packages

$ apt-get clean (This command removes everything from the /var/cache/apt and /var/cache/apt/archives directory.)

10. Remove packages that can no longer be downloaded

$ apt-get autoclean

Options provided with apt-get
-f : fix broken dependencies
-m : continue if archives are unlocatable
-u : show a list of upgraded packages as well
-s : reports on the status of the package listed

For more information, visit   http://wiki.debian.org/Apt  or $apt-get –help

Try this when you are free, “This Apt has Super Cow Powers” :) ,

$ apt-get moo

Subscribe to fortystones.
Follow @fortystones on Twitter.
Get updated from our Facebook Fanpage.

Share

Related Posts

About the Author: Rabi C Shah

Rabi C Shah, pursuing his under-graduate program with a major in Information Technology in Indian Institute of Information Technology Allahabad (IIIT-A), is a passionate programmer. A Photoshop enthusiast, he is interested in Linux, C and C++. Rabi has completed many mini college projects in java and php. He is the Linux guy of our fortystones team.

7 Comments + Add Comment

  • sudo apt-get autoremove should also be considered as it cleans the system by removing those files which are no longer in use.

    • I have not tried this but how do you define which file is ‘no longer in use’?

  • Great set of things on package tool, nice one, keep them coming!!..

  • That is a well formatted man page.

  • Why did you give up on examples after 1.1?

  • Unfortunately most people don’t show you how to use the man page, they simply show you how to access it. If you’re bright, you’ll figure it out on your own, but if you’re like me, it’ll take you a while to get what all the “-[word] –something” stuff means

  • I’ll not define the files, when you will type “sudo apt-get autoremove”, prompt itself will show message regarding files.

Leave a comment

*