Lucid Tips

Easily understood tips that make your computing experience easier

Managing packages using apt on Ubuntu

On Ubuntu Synaptics package manager allows you to search and install packages. It is essentially a front end to APT (Advanced Packaging Tool) and package management can be performed from the command line as well. This can be very handy if you are using SSH to connect to a remote machine and do not have the luxury of using the graphical interface.

apt-cache and apt-get are the commands that work with APT and help searching/installing packages.

Disclaimer: The instructions provided in this howto make changes to your system. Please proceed with caution. I am not responsible for loss of data or damage to computers.

apt-cache does not make any changes to the system but does provide options to search the package metadata. Using apt-cache is very easy and the syntax to search for a package is

apt-cache search <searchstring>

For example the following command can be used for searching packages related to Java.

apt-cache search java

Note that it searches through the package name and description and the search result is a big list. The grep command is handy to filter the list

apt-cache search java | grep sun

Now that the package is identified you can see additional details about the package

apt-cache show <package>

This will show details about the package such as maintainer, version, dependencies, long description etc. For example to see details about Sun Java5 JDK the command would be

apt-cache show sun-java5-jdk

If you wish to installĀ a package the command is apt-get. Since apt-get makes changes to the system you need to run it using sudo and will be prompted for password.

sudo apt-get install <package>

For example to install Sun Java5 JDK the command would be

sudo apt-get install sun-java5-jdk

Note that apt-get will automatically identify all the dependencies to run the package being installed.

Multiple packages can be installed at the same time using the syntax

sudo apt-get install <package 1> <package 2> ... <package n>

The syntax to remove a package is

sudo apt-get remove <package>

Multiple packages can be removed at the same time as well

sudo apt-get remove <package 1> <package 2> ... <package n>

apt-get can also be used to apply the latest patches to the system.

To update the list of packages available run the following command. This will only download the list of packages and not apply them.

sudo apt-get update

Now to download and apply the patches run the command

sudo apt-get upgrade

APT-HOWTO manuals at debian.org provide good information on APT and its features and also provides good examples.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Google
  • Slashdot
  • StumbleUpon
  • Technorati

No comments yet. Be the first.

Leave a reply