Ubuntu – Where does apt-get install get packages from

apt

When I install something in the terminal, such as chromium, I would type in

sudo apt-get install chromium-browser

How does the terminal know that chromium-browser is a valid package to install? Is there some list of all packages that can be installed? How does it find the packages?

Best Answer

Whenever you call apt-get update the repositories contained in the sources.list get read, this tells apt-get from where to get packages lists. This list get downloaded and stored in /var/lib/apt/lists for posterior use. These are lists of all packages available from the repositories you selected. Even if you remove your sources.list, this list will be available for APT. That's why you should always do update whenever you add/remove/modify a repository, to keep these lists updated.


How does the terminal know that chromium-browser is a valid package to install?

"The terminal" knows nothing. APT read all the lists in /var/lib/apt/lists and determine if the package is available. If the package is not found in any of the lists, you will get:

E: Unable to locate package <package>

Is there some list of all packages that can be installed?

This changes from repository to repository. Your local copy/list of your active repositories is found in /var/lib/apt/lists.


How does it find the packages?

$ sudo apt-get check
Reading package lists... Done
Building dependency tree       
Reading state information... Done

The line of interest is

Reading package lists... Done

which tells you that APT reads the list, from /var/lib/apt/lists.

Related Question