9

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?

Braiam
  • 67,791
  • 32
  • 179
  • 269
reesjones
  • 191
  • 1
  • 1
  • 5
  • In Ubuntu Software installation is different. It is so secured. They are installed from a trusted pool. Advanced and freely available applications which needed for majority of the functions in computing are in that pool. You can select and install from either Software Center or running sudo apt-get install [PACKAGENAME] command. –  Dec 22 '13 at 09:56
  • plz ask a single question. – Avinash Raj Dec 22 '13 at 10:31

3 Answers3

7

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.

kiri
  • 28,246
  • 16
  • 81
  • 118
Braiam
  • 67,791
  • 32
  • 179
  • 269
2

apt-get searches for the specified package in the repositories given in the /etc/apt/sources.list file and /etc/apt/sources.list.d directory.

Avinash Raj
  • 78,556
0

To show where apt-get install gets a specific package (e.g. chromium-browser) from, open the terminal and type:

apt-cache policy chromium-browser | grep $(lsb_release -sc)

The results will be one or two lines showing the exact update server mirror and the exact repository from which apt and apt-get in your Ubuntu downloads the chromium-browser package. There's no need to search anywhere because it's all there in either one or two lines of output. The results of apt-cache policy <package> | grep $(lsb_release -sc) are printed on two lines in the case where there are two alternate repositories, otherwise they are printed on one line if there's just one repository that contains <package>.

Explanation:

  • $(lsb_release -sc) is the codename for your Ubuntu release

  • apt-cache policy <package> - prints out the priorities of each source of <package>

karel
  • 114,770