Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

By sudo add-apt-repository '<deb url codename component>', a repository is added to the /etc/apt/source.list file.

By sudo add-apt-repository ppa:<user>/<ppa-name>, I saw that all the ppa repositories are added to /etc/apt/source.list.d dir:

$ ls /etc/apt/sources.list.d/
  1. Can a ppa repositories be added to the end of /etc/apt/source.list file, instead?

  2. Why are ppa repositories are treated differently from non-ppa ones?

  3. Are there other non-ppa repositories treated similarly as ppa ones?

  4. Will sudo add-apt-repository '<deb url codename component>' add a ppa repository to /etc/apt/source.list, or to some files under /etc/apt/source.list.d?

share|improve this question
  1. Yes, PPA's can be added to /etc/apt/source.list, in similar way to debian (deb) repositories.

    deb<ppa-name>/ppa/ubuntu <release-code-name> main 
    deb-src<ppa-name>/ppa/ubuntu <release-code-name> main

    An example for WineHq: ppa debian repository link

  2. Thought just matter of keeping things somehow easily managed, leaving /etc/apt/source.list only for official release repositories. All additional repositories goes to /etc/apt/source.list.d/. Easy to:

    1. add (creating file then editing existing one, a partial solution to avoid duplicates too)
    2. remove (with parsing a /etc/apt/source.list looking to related line)
    3. backup/restore (using compressed archive of /etc/apt/source.list.d/ folder)
    4. avoid breaking things with much edits targeting /etc/apt/source.list
  3. PPA are always added to /etc/apt/source.list.d/ folder if wrote it in ppa:<user>/<ppa-name> form.

    Reference: man add-apt-repository

           REPOSITORY can  be  either  a  line  that  can  be  added  directly  to
           sources.list(5),  in the form ppa:<user>/<ppa-name> for adding Personal
           Package Archives, or a distribution component to enable.
           In  the   first   form,   REPOSITORY   will   just   be   appended   to
           In  the second form, ppa:<user>/<ppa-name> will be expanded to the full
           deb  line  of  the  PPA  and   added   into   a   new   file   in   the
           /etc/apt/sources.list.d/  directory.   The  GPG public key of the newly
           added PPA will also be downloaded and added to apt's keyring.
           In the third form, the given distribution component will be enabled for
           all sources.
  4. Well, it seems only PPA's as shortcut goes to /etc/apt/sources.list.d/. add-apt-repository or apt-add-repository is a Ubuntu specific tool. All I can think of is just Ubuntu decision to keep personal PPA's out.

    However you can modify it to use only /etc/apt/sources.list. It's a python3 script. Modify /usr/bin/add-apt-repository line:

    shortcut = shortcut_handler(line)

    replace it with this one below to resolve ppa shortcut form to a deb line form:

    shortcut = shortcut_handler(shortcut_handler(line).expand(sp.distro.codename)[0])
share|improve this answer
Note that, strangely enough, non-PPA repos will get added to /etc/apt/sources.list. – saiarcot895 Jul 11 '14 at 16:32
@saiarcot895, I think add-apt-repository was written to ease the work with PPA in 1st place. Here the commit description when it was added: "new helper script "add-apt-repository" that can be used to enable a repository from the commandline. Useful for e.g.'add-apt-repository ppa:gnome-desktop'".… – Sneetsher Jul 11 '14 at 17:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.