Working with APT on a Debian Server

Debian GNU/Linux and other OSes based on the free and open source operating system, such as Ubuntu, use a package management system called APT to install, update, and remove software.  APT is very powerful and easy to use.  You can access it from the command line via SSH, giving you full control over the software you run on your dedicated server.

To install a software package with APT, use the following command, logged in as root:

apt-get install package-name

Replace “package-name” with the name of the package you want to install.  This can be tricky, however, if you are not sure of the exact name.  Apt-get will not guess for you.  To search your APT repositories, type:

apt-cache search package

This will search the package name and description.

Whenever you add new repositories or need to make sure you have updated any changes, you should run:

apt-get update

To remove a package, type:

apt-get remove package-name

To add a new repository to APT, edit the /etc/apt/sources.list file and append the deb string associated with that repository.  For example:

deb stable main contrib non-free
deb-src stable main

Most repositories have secure gpg keys associated with them.  You will need to add those keys in order to install packages from those servers.

gpg –keyserver –recv-key DSF82N3F2901F39

gpg -a –export DSF82N3F2901F39 | apt-key add –

Finally, when you want to run the latest updates for your OS, type:

apt-get upgrade

For more information about APT and the various commands associated with it, consult your Linux distribution’s documentation.