Can I consolidate lines in /etc/apt/sources.list

I am guessing -- but would like to confirm -- that, in the /etc/apt/sources.list file, there is no reason why one cannot replace these three lines:

deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ xenial-security restricted main

deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ xenial-security universe

deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ xenial-security multiverse

with this one line:

deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ xenial-security main restricted universe multiverse

Is this (as long as the lines have the same repository-URL and distribution type) correct? Or is there some purpose to having them as separate lines with the component-type spread among the different lines?


Your assumption is right - as is your example. Consolidation can be done and sources are often defined that way.

So far, the only reason that crossed my mind for splitting them up is that universe and multiverse are pretty big repos that take time to update and influcence the size of the resulting database - and thus the risk something breaks. If you have single lines they are easy to comment out :))

One might think that is does not make a big difference. But once you start automating an infrastructure the automation tools tend to do apt-get update a lot and it makes sense to reduce that time if the packages involved are not needed.

But apart from that I can only think of better documentation targeting in the original sources.list file :))


Debian has a nice page that confirms your idea:

  • Debian Wiki: Example sources.list

Thus the syntax of:

Archive type --> Repository URL --> Distribution --> Component --> Component --> Component

Represents your suggested line of:

deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ xenial-security main restricted universe multiverse

and should be perfectly ok.

Explanatory notes:

  1. Archive type: Normally deb or deb-src, in your case deb
  2. Repository URL: The address of the repository
  3. Distribution: The class of release, in your case 'xenial-security'
  4. Component: restricted, main, universe, multiverse which can be presented, as you have suggested, one after the other separated by a space

References:

  • Debian Wiki: sources.list

Yes. You can. You can use

deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ xenial-security restricted main universe multiverse

for a given archive or suite-type like xenial-security, xenial-updates or xenial Instead of having 4 lines.

So the above line is same as having these 4 lines

deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ xenial-security restricted     
deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ xenial-security main 
deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ xenial-security universe     
deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ xenial-security multiverse

But I'd advice to split the lines into 4. This helps in quickly locating and editing lines from command line.