Debian’s APT (Advanced Packaging Tool) is an amazing program that adds greatest level of manipulability to the distributions that use it. It enables the user to control the software that runs on their computer, making it exactly the way they like it, without any extra programs that do not get used. This is unlike any other non-*nix operating system, giving A clear advantage, in my opinion, to it’s users.
Essentially APT is a front end to dpkg, a base level program for installing and removing and providing information about .deb packages. Going into depth of dpkg and .deb files is for another time, but briefly a .deb package is a way of puting a program into a container that makes it’s installation much simpler for the end user and dpkg was written for handling these packages.
APT is also able to use the RPM package management system, using the apt-rpm method (explained later). This is a newly acquired feature of APT which I believe that was added to make the Debian distribution POSIX compliant. RPM was created for the Red Hat Linux distribution as a simple package management system which has solid dependency handling.
Now APT is available on all Debian based distributions such as Ubuntu, Mint, Knoppix and a number of others, as well as Solaris (not open any more). This means that of all the users of Linux distributions, many have access to APT. Lets see the program in action. Open the terminal and enter the following
sudo apt-get update
To run the APT program you must run as a super user or provide super user privileges. You will also notice that there is the `tack get` addition of the apt program. This is because the program has many sub layers, with others such as apt-cache, apt- secure and apt-key. The update program updates the latest information from the sources list.
The sources list is the location of the Debian packaged programs that are installable via a direct download from apt-get. Finding the best sources for the apt-get program will be in a quick tip, for now we will assume that all the sources will be the optimal ones. Now lets perform a second command related to the sudo apt-get update command, upgrade
sudo apt-get upgrade
This command upgrades the current installed programs in a number of ways. First it checks to see if all the packages are the latest version of the installed programs. If there are new versions it does a dependency check and asks if you would like to update at which stage it will let you know of any other programs need to be installed. (hit enter here) It will then proceed to update and install until your current installed programs are how they should be at their newest version.
How about installing programs. Simple ! Just use the sudo apt-get install command. The trick is knowing exactly what program you need. For example, I am writing a program which works with a database in c. I need the mysql header files which are not installed by default. The trick with accessing header files is to download the development packages of the need programs so I used the following install command.
sudo apt-get install libmysqlclient-dev
These 3 main commands can handle 90% of your apt needs. Below is a list that i have compiled about commands and there functions that you may come across needing in your use of the program.
sudo apt-get remove `program`
This removes the installation of the program specified but still lives on the system
sudo apt-get autoremove
This automatically removes all the programs which are not being used and are not depended on by any other programs.
sudo apt-get clean
This cleans the archives of the downloaded programs. Any Archives that are not needed are removed, freeing up space.
sudo apt-get autoclean
This automatically removes the archives that are not needed and any dependencies as well
sudo apt-get source `program`
This downloads a source version (if available) that will need other install methods, in order to examine the source code and build specifically the way you choose.
deb `link` `version` `relationship`
This adds a source to the list. Link is source location, version is the word number of the version being used eg ubuntu uses “hardy” or your version equivalent and debian would use ‘lenny’ for v5 or ‘squeeze’ for v6. The relationship is a little more complex. Most likely it will be partner, But it may equally be universe or multiverse.
apt-cache search `program`
searches all repositories and list ever instance of the program. This is a great way to find a program that you are looking to download.
sudo apt-get dist-upgrade
This updates packages which have may have any number of dependency discrepancies.
This list is incomplete. Its a ‘working copy’ of the most commonly used apt commands. The important thing to remember is to run the update before you start working with apt so that you have the latest information, as well as anytime you add or remove sources.
If you have any questions or use any commands relating to apt that I haven’t listed, please let me know in a comment below.