Adding Third-Party APT Repositories
On Debian-based Linux servers, APT is the package manager of choice. By default, running apt-get will connect to the Linux distribution’s main package repository. In most situations, this is enough, but there are situations where you might want to add additional repositories. For example, if you are using a special web-based control panel or other unique software, the vendor may provide you with an update repository for that software.
1. To add repositories to your apt sources, you will need to login as root.
su
2. Edit the sources.list file found in the apt configuration directory:
nano /etc/apt/sources.list or vi /etc/apt/sources.list
3. Copy the source line given to you by the repository maintainer, and paste it on an empty line at the bottom of the file. It should look something like this:
deb http://websiteurl.net/debian sid main contrib free
3. Save the file and exit.
4. After saving, the new packages will not show up in the cache until you refresh it. Run the following command:
apt-get update
Now, you should see the new packages when you search and try to install them. If you ever need to disable the repository, simply place a “#” in front of it in the sources.list file to comment out the line. To remove it completely, just delete it. Anytime you make changes, be sure to run “apt-get update” again.
Tag: apt-get, debian, linux, repository, server, software, sources.list
Upgrade Your Server with APT
Debian-based servers have a unique ability to easily upgrade from one major version to another without re-installation and will little reconfiguration.
To begin you will need to specify the location of the new packages in /etc/apt/sources.list. In other words, APT will need to know where the new packages are.
To upgrade an entire distribution to a new version of it, just run the following command as root:
apt-get dist-upgrade
There are a couple of things to consider when performing a full upgrade. Do you really need any of the latest packages? If your current distribution is still supported, it may not be worth the risk, and the risk is that some packages might not install correctly. Furthermore, downloading and installing so many packages will slow down your server while it is upgrading.
It is best to weigh the pros against the cons and then decide if your system really needs the upgrade or if you can keep it updated and secure with the current version.
Tag: apt, apt-get, debian, distribution, linux, server, upgrade
How to manually install stubborn APT packages
Question: What do I do when I get the following error with apt-get: error processing /var/cache/apt/archives/packagename_0.80.1-1_all.deb : trying to overwrite ‘libsomething.1.0.so, which is also in “libotherpackage”?
Answer: These types of errors can be very annoying when trying to upgrade packages on a Linux server with apt-get. Sometimes these can be caused by adding third-party repositories, and other times it’s just an error by the distribution developers. At any rate, sometimes the solution can easily be solved with:
# apt-get -f install
If that works, you are done, but if it does not, you can try a more direct approach using dpkg, which is the program apt uses to install packages. From the root command prompt, enter:
dpkg --force-all -i /var/cache/apt/archives/packagename_0.80.1-1_all.deb
This will install the package and overwrite the offending file, ignoring any errors. Make sure the package you are installing is the right one before you do this. Otherwise, you might really do harm to your system, but most times the files truly are identical and have just been moved from one package to another. With that simple command, your problem should be solved.
Tag: apt, apt-get, dpkg, linux, packages, server, upgrade
Useful APT commands

In a previous post, we covered some of the basics of using apt-get to download and install packages for your Linux server. There are several commands that you can append to “apt-get” in order to perform various tasks. Here are a few:
1. “apt-get clean” By default, APT saves a cache of the packages you have downloaded in a directory on your computer. It might be store somewhere like /var/cache/apt/archive. Sometimes a package might be broken when you originally download it. After it is fixed, you would to delete the downloaded package and run apt-get again.
2. ‘”apt-get autoclean” Autoclean will essentially do the same thing as “clean”, but it will only remove the old packages.
3. “apt-get autoremove” APT automatically detects packages that you might have needed for dependencies of packages you no longer have or packages that you might not use, for various reasons. Running “apt-get autoremove” will wipe those packages out. Use it with caution.
4. “apt-get purge” This command needs a qualifier and can be used to delete all traces of a package from your Linux server, including the downloaded archives.
Tag: apt-get, download, install, linux, packages, server
Fixing APT problems
Question: I get an error on my server with apt-get, and it will not let me install any new packages. What should I do?
Answer: Depending on the error, there are a number of solutions you can try. The first is to tell APT to resolve any unfinished transactions or unmet dependences. As root or with sudo, type:
apt-get -f install
This will finish any installs that might have been interrupted or remove packages that were installed manually and cannot be completed because of dependency problems. If your packages were downloaded and installed but did not finish configuring, you can also run dpkg as root or with sudo:
dpkg --configure -a
This will finished any outstanding configurations. If those two general fixes do not work, you will need to diagnose the specific problem. Try searching some Linux forums or specific support pages for your distribution. Your web hosting provider might also have a knowledge base. Chances are, if you have a problem, others have experienced it as well.
Tag: apt, apt-get, linux, packages, server, web hosting
How to perform upgrades with apt

Question: What is the difference between apt-get upgrade and apt-get dist-upgrade?
Answer: Apt-get upgrade is designed to update your Linux server packages to their latests versions. It will only upgrade the packages that are currently installed. Apt-get dist-upgrade will not only upgrade the current packages but will also install any new packages that may be needed or that were added to the distribution.
In a real-world situation, let’s say you have an Ubuntu server. Ubuntu releases updates, fixes, and security patches on a routine basis. To get those updates, you would run APT:
sudo apt-get upgrade
This would bring your server up to date with all patches and fixes, but you would still essentially have the same version of the distribution. On the other hand, every six months, they release a complete new version of the distribution that sometimes has new packages and new dependencies for packages. To do a complete in-box upgrade you would enter:
sudo apt-get dist-upgrade
Both are useful and needed, but for different reasons. Make sure you know which one you need before you try them.
Tag: apt, apt-get, linux, server, ubuntu, upgrade
Searching for applications with APT

Using “apt-get install” works perfectly well as long as you know the name of an application, but if you do not, it becomes a guessing game. Fortunately, APT has a search tool you can use to find the applications or types of applications you need for your Linux server.
APT can search the repository cache on your server with the command “apt-cache search”. For example, if you want to search for Apache, enter as root:
apt-cache search apache
But suppose you want a module or plugin related to your web server but you do not know exactly what it is called or even the generic name for it. You can perform a search like this:
apt-cache search “web server”
This will search for any application that has “web server” in the name or description. APT will print a list of the names of the applications followed by descriptions:
libapache2-authenntlm-perl - Perform Microsoft NTLM and Basic User Authentication
libapache2-mod-bt - BitTorrent tracker for the Apache2 web server
libapache2-mod-lisp - An Apache2 module that interfaces with Lisp environments
libapache2-mod-ocamlnet - OCaml application-level Internet libraries - netcgi2 Apache2 connector
libapache2-mod-ruby - Embedding Ruby in the Apache2 web server
libapache2-mod-shib2 - Federated web single sign-on system (Apache module)
libapache2-mod-vhost-hash-alias - Fast and efficient way to manage virtual hosting
Find the one you want and only enter the name of the applications:
apt-get install libapache2-authenntlm-perl
Photo: Flickr
Tag: apache, apt, apt-cache, apt-get, linux, server, software
Installing applications with APT
In a previous post, I explained how to install APT on a Linux server that does not have it. In this post, you learn how to use APT on any server that has it installed. Debian and Debian-based distributions, such as Ubuntu, use APT by default. The basic command for APT is “apt-get” in combination with other indicators. For example, if you want to install something, you use “apt-get install”.
To install Apache 2, you would type as root (or preceded by sudo):
apt-get install apache2
(or whatever the name for Apache is in your distribution)
APT uses a cache of repository lists to determine if something is available. Before installing anything, be sure to update the cache:
apt-get update
To remove an application, replace “install” with “remove”:
apt-get remove apache2
Be very careful with APT and keep in mind that any applications you install or uninstall will affect your server and every user account on it.
Tag: apt, apt-get, install, linux, server