The apt-get package management system can trip you up, even though it's supposed to simplify your work. Here are some practical pointers to help you get around various apt-get gotchas.
The apt-get package management system enables administrators to keep a system updated with the latest, greatest packages (or install previously uninstalled packages) using simple command-line input. But not everyone finds apt-get easy to use. Some people have trouble remembering commands or keeping track of repositories. Others just don't like the command-line interface. Never fear. No matter what problems you have with apt-get, there are ways to make it easier to use. Let's examine some of those ways.Note: This information is also available as a PDF download.
#1: Keep your repositories separate
I often add new repositories for installing specific packages, such as Enlightenment. But if I were to keep adding those repositories to my sources.list file, it would quickly become confusing. It would also take longer to weed through it to find the right repository to edit. To make things easier, I create a separate file for each new repository I add that is outside of the normal distribution repository. Make sure after you add a new sources file you run apt-get update so apt will catch the new repositories.
#2: Automate apt-get
This trick is handy if you I you want to keep all your packages up to date on a regular basis. The best method of handling this is with the package cron-apt. You can install cron-apt with the apt-get install cron-apt command. This only downloads the new updates and e-mails the admin that they are available. The cron-apt tool will NOT automatically update the packages — and this is a good thing. You don't want every package always automatically updating.
#3: Make apt-get stop asking for your installation CD/DVD
This can get really annoying if you're constantly installing standard packages. To stop this behavior, open up /etc/apt/sources.list and comment out the line that starts with deb cdrom. (In Ubuntu, it is often the first line.) Once you've done this, you won't be prompted for your installation media.
#4: Use apt-get to install from source
No, this doesn't really make apt-get easier. But it uses apt-get to make a process many fear a whole lot easier. Say, for instance, you want to install the Balsa e-mail client from source. To do this, issue the command sudo apt-get build-dep balsa. This will download all of the dependencies for the application. Next, issue the command sudo apt-get -b source balsaI, which will create the .deb package for you to install. This creates a binary package that is specific for your machine. It's not necessarily any easier, but it's certainly worthwhile when you know you need to install from source.
#5: Use a GUI for installation
One of my favorite installation GUIs of all time is Synaptic. It's simple and reliable. Synaptic offers an outstanding means of searching for packages, installing packages, and updating packages. Of course there are more GUIs for apt-get. For example, Aptitude is an outstanding graphical front end for apt-get.
#6: Use the update-manager front end for updating packages
In the world of Ubuntu, apt-get has an excellent separate front end for updates only. This front end, update-manager, not only handles package updates, it also does distribution updates so you can go from Hardy Heron to Gusty Gibbon without a hitch. Of course update-manager, like synaptic, must be run with sudo privileges.
#7: Run apt-get update on a regular basis
If you run apt-get update, say, once a month, you're going to have to wait for the system to sift through a month's worth of updates. So when you run apt-get install for a specific package, you know your repositories have already been updated to contain the most recent versions of packages.
#8: Make sure you are installing only stable packages
Sometimes, two versions of an application are available (if you have repositories in your sources that point to both): stable and unstable. You most likely do not want to install the unstable version of certain packages. To avoid this, you can add either the /stable or /unstable switch to the command, like so: apt-get install PACKAGE/stable (where PACKAGE is the name of the package to install.)
#9: Help apt-get get around a proxy
If you work behind a proxy server, it can be a real hassle trying to get apt-get to work. To get around your proxy, you need to add the following line to the /etc/environment file:
where PROXY_ADDRESS:PORT is the actual address and port of your proxy server. Once you have the correct additions, run the command source /etc/environment to apply the changes.
#10: Avoid the 403 error with ftp
If you're having trouble getting through a firewall due to http restrictions, you can change all the http references to ftp and then run apt-get update to apply the changes. You should have no problems with 403 errors any more.
These quick tips should make your life with apt-get go more smoothly. Of course, the uber-easiest trick is to jump to number 5 and use the GUI. But there are many instances where the GUI won't make anything easier. For those instances, the other nine tips can help you out.
Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website getjackd.net.