• Check it out - we have a chatbot! Go ask TuxBot a question in the Ask Tuxbot section!

Linux+: Applications 20 – Manage Repositories with apt-get


Jarret W. Buse

Linux+: Applications 20 – Manage Repositories with apt-get

The wonderful thing about using apt-get is the ease of finding packages. The source of the packages are repositories. Repositories contain the packages to be downloaded and installed to your system.

The commands and subcommands for managing the repositories are as follows:

  • add-apt-repositories
  • update
  • clean
  • autoclean
The list of repositories used by apt-get are found at /etc/apt/sources.list or at /etc/apt/sources.list.d/official-package-repositories.list which looks like the following:

# Do not edit this file manually, use Software Sources instead.
deb http://packages.linuxmint.com rebecca main upstream import #id:linuxmint_main
deb http://extra.linuxmint.com rebecca main #id:linuxmint_extra
deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu/ trusty partner

As you can see from these listings, there are other components used for each listing. These components are explained:

  • Main - fully supported software (official)
  • Restricted -packages are not available under a completely free license
  • Universe - Community maintained software (unofficial)
  • Multiverse – pay for packages
For example, looking at the line “deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse”. This repository is located at “http://archive.ubuntu.com/ubuntu. The repository stores packages for the “trusty” system. Trusty is a codename for version 14.04 LTS of the Ubuntu operating system. The packages contained on this repository are “Main”, “Restricted”, “Universe” and “Multiverse”.

NOTE: Each Linux distro will have its own base repository which is set when the Operating System (OS) is installed. Other repositories can be added as needed.

Package specific repositories can be added using a Personal Package Archive (PPA). For example, individual programmers or software houses can offer their product through a PPA. Once the PPA is added to the repository list, the packages can be installed and updated from the new repository. The PPAs are added repositories other than the distro's default list.

To add a repository to the default list, use the command “add-apt-repository”. The syntax is: “add-apt-repository [options] repository. Options used for the command are:
  • -h (--help) - displays help message
  • -m (--massive-debug) – lists debugging information
  • -r (--remove) - removes the specified repository
  • -y (--yes) - assume the answer “yes” to all queries
  • -k (--keyserver) - uses a custom keyserver URL instead of the default
  • -s (--enable-source) – allows the downloading of the source packages from the
For instance, to add the PPA for the package Super Tux Kart, the PPA is
ppa:stk/dev”. The command would be:

sudo add-apt-repository ppa:stk/dev

In this case, the PPA is designated as “ppa:user/ppa-name”. The PPA user is “stk” and the PPA Name is “dev”.

To remove the PPA, use the “-r” option. The command would be: “sudo add-apt-repository -r ppa:stk/dev”. Now, the PPA is removed from the repository list.

Once a PPA is added or removed, the repository package list must be updated. Once updated, the package list from
the new PPA will be included for installing packages from the PPA.

So, after adding the PPA, to update the list use the command “sudo apt-get update”. Then to install the package from the repository,
use the command “sudo apt-get install SuperTuxKart”.

NOTE: Whenever an update is found on the PPA, it can be downloaded as an upgrade
(sudo apt-get upgrade).

The “update” subcommand for apt-get allows all of the items in the
repository list to be updated. Any packages which have been changed
on a repository or PPA will be in the newly released
list. The more names in the repository list, the longer the list
update will take when being performed.

When package files are downloaded, they are stored in /var/cache/apt/archives/. After some time, this folder can hold a lot of package files. To clean the
cached packages, use the “clean” subcommand in the fashion “sudo apt-get clean”.

All files are deleted in the folder /var/cache/apt except /var/cache/apt/archives/ and /var/cache/apt/archives/partial/.
These two folders contain the lock files. The lock files are opened by any process running the “apt-get” command. If another process
is started to also run the “apt-get” command, the second one will not be able to perform the command. When a process starts using
“apt-get”, it locks the “lock files” to prevent another process from using “apt-get”. In this manner, the repository
lists and such cannot be corrupted by two processes sharing the information.

Some files downloaded into the cache can become outdated. If a package is no longer available by a repository, the subcommand
“autoclean” can be used to remove only non-existent packages from the cache.

Be aware that if the repository list is lost or repository entries are accidentally erased, then “apt-get” will not function as you
desire. Be careful of PPAs you add to your repository list. Some PPAs may offer harmful packages, so be careful.


  • slide.jpg
    32.9 KB · Views: 47,545

MALIBAL Linux Laptops

Linux Laptops Custom Built for You
MALIBAL is an innovative computer manufacturer that produces high-performance, custom laptops for Linux.

For more info, visit: https://www.malibal.com

Members online

Latest posts