Restore default apt repositories in sources.list from command line











up vote
15
down vote

favorite
7












I am looking for the best method to restore /etc/apt/sources.list to default from the command line.



Is there no way to reference the source code of the package which generates this file or something like that? I want a trusted and version-independent way of restoring this file.



Solutions Ruled Out



Before you mark this as a duplicate, note that I have reviewed this question already. It is only applicable if you have the Ubuntu GUI available. This question is specific to the command line.



I have also reviewed this question where the accepted solution is someone pasted the contents of their sources.list file. This is not an appropriate way to restore the file as the intentions of the person providing the file contents cannot be verified and the file is subject to change with new releases.



I checked out the generator at simplelinux.ch, but this is also not from Ubuntu so I do not plan to use it.










share|improve this question




























    up vote
    15
    down vote

    favorite
    7












    I am looking for the best method to restore /etc/apt/sources.list to default from the command line.



    Is there no way to reference the source code of the package which generates this file or something like that? I want a trusted and version-independent way of restoring this file.



    Solutions Ruled Out



    Before you mark this as a duplicate, note that I have reviewed this question already. It is only applicable if you have the Ubuntu GUI available. This question is specific to the command line.



    I have also reviewed this question where the accepted solution is someone pasted the contents of their sources.list file. This is not an appropriate way to restore the file as the intentions of the person providing the file contents cannot be verified and the file is subject to change with new releases.



    I checked out the generator at simplelinux.ch, but this is also not from Ubuntu so I do not plan to use it.










    share|improve this question


























      up vote
      15
      down vote

      favorite
      7









      up vote
      15
      down vote

      favorite
      7






      7





      I am looking for the best method to restore /etc/apt/sources.list to default from the command line.



      Is there no way to reference the source code of the package which generates this file or something like that? I want a trusted and version-independent way of restoring this file.



      Solutions Ruled Out



      Before you mark this as a duplicate, note that I have reviewed this question already. It is only applicable if you have the Ubuntu GUI available. This question is specific to the command line.



      I have also reviewed this question where the accepted solution is someone pasted the contents of their sources.list file. This is not an appropriate way to restore the file as the intentions of the person providing the file contents cannot be verified and the file is subject to change with new releases.



      I checked out the generator at simplelinux.ch, but this is also not from Ubuntu so I do not plan to use it.










      share|improve this question















      I am looking for the best method to restore /etc/apt/sources.list to default from the command line.



      Is there no way to reference the source code of the package which generates this file or something like that? I want a trusted and version-independent way of restoring this file.



      Solutions Ruled Out



      Before you mark this as a duplicate, note that I have reviewed this question already. It is only applicable if you have the Ubuntu GUI available. This question is specific to the command line.



      I have also reviewed this question where the accepted solution is someone pasted the contents of their sources.list file. This is not an appropriate way to restore the file as the intentions of the person providing the file contents cannot be verified and the file is subject to change with new releases.



      I checked out the generator at simplelinux.ch, but this is also not from Ubuntu so I do not plan to use it.







      command-line apt repository






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 13 '17 at 12:24









      Community

      1




      1










      asked Feb 17 '15 at 18:01









      Ryan Burnette

      178115




      178115






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          17
          down vote



          accepted










          I'm not sure what you want, but:




          • The parent repository is always http://archive.ubuntu.com/ubuntu - everything else is a mirror of this. The other primary mirrors all have a domain of the form <cctld>.archive.ubuntu.com, where the two character short code is the Country Code Top Level Domain. You can find additional mirrors with their status at Launchpad.

          • The distribution codename is part of the channel (the third term). You can use lsb_release -sc to find that out, and it's the first word of the release pretty name in lowercase (trusty for Trusty Tahr, for example).

          • There are five channels: <codename>, <codename>-security, <codename>-updates, <codename>-backports and <codename>-proposed. The first is necessary as it is the base, the second is highly recommended as it contains security fixes, the fourth only if you need some package backported from a newer release and the fifth only if a developer asks you to enable it for testing a possible fix.

          • There are four repository sections: main, multiverse, universe and restricted (What's the difference between multiverse, universe, restricted and main?)


          So you can always create a safe sources.list which contains just:



          deb http://archive.ubuntu.com/ubuntu <codename> main multiverse universe restricted
          deb http://archive.ubuntu.com/ubuntu <codename>-security main multiverse universe restricted


          If you want a command to do this:



          printf 'deb http://archive.ubuntu.com/ubuntu %s main multiverse universe restrictedn' $(lsb_release -sc){,-security} > /etc/apt/sources.list




          In addition to the Launchpad list, the list provided by the Software Sources program is
          from /usr/share/python-apt/templates/Ubuntu.mirrors, which is from the python-apt-common package. This package is only an indirect Suggests dependency of apt, so it may not be installed by default on a server.






          share|improve this answer























          • That's exactly what I wanted clarification on. Thank you!
            – Ryan Burnette
            Feb 18 '15 at 23:47










          • this answers perfectly for boths posts (the one linked and this one)
            – Brian Thomas
            Aug 16 '16 at 2:37










          • But you would still have to validate this answer with the documentation on the Ubuntu website itself as you cannot verify the intentions of the person providing this answer?
            – Herbert Van-Vliet
            Nov 24 at 11:43


















          up vote
          6
          down vote













          If you understand what each line stands for in /etc/apt/sources.list, you can generate your own list. For example a line in my sources.list is,



          deb http://archive.ubuntu.com/ubuntu/ trusty main


          It has 4 sections:




          • Section 1: The first section is deb here which means it is a repository of all the binary packages. only other possible value is deb-src which means its a repository of source codes.

          • Section 2: This section contains the URI of the repository (http://us.archive.ubuntu.com/ubuntu/ in this case). The URI can vary for mirrors e.g. if you want to use the official US mirror then the URI will be http://us.archive.ubuntu.com/ubuntu/.

          • Section 3: It contains the codename (and channel name) of the release you are using, in this case trusty which is the codename of my Ubuntu release (14.04 LTS). you can find yours by lsb_release -sc. For example, If you are using 12.04 the codename will be "precise". Now to declare other channels e.g. to declare security channel you need to use trusty-security.


          • Section 4: This section contains "section names" of the repository. There are usually 4 section names used: main, restricted, universe, multiverse. You can put all the section names in the same line of declaring a repository or you can use different lines for each of the sections but there must not be any duplicate entry. If you read the /etc/apt/sources.list, then you will see the description of packages each of these sections contains.







          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f586595%2frestore-default-apt-repositories-in-sources-list-from-command-line%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            17
            down vote



            accepted










            I'm not sure what you want, but:




            • The parent repository is always http://archive.ubuntu.com/ubuntu - everything else is a mirror of this. The other primary mirrors all have a domain of the form <cctld>.archive.ubuntu.com, where the two character short code is the Country Code Top Level Domain. You can find additional mirrors with their status at Launchpad.

            • The distribution codename is part of the channel (the third term). You can use lsb_release -sc to find that out, and it's the first word of the release pretty name in lowercase (trusty for Trusty Tahr, for example).

            • There are five channels: <codename>, <codename>-security, <codename>-updates, <codename>-backports and <codename>-proposed. The first is necessary as it is the base, the second is highly recommended as it contains security fixes, the fourth only if you need some package backported from a newer release and the fifth only if a developer asks you to enable it for testing a possible fix.

            • There are four repository sections: main, multiverse, universe and restricted (What's the difference between multiverse, universe, restricted and main?)


            So you can always create a safe sources.list which contains just:



            deb http://archive.ubuntu.com/ubuntu <codename> main multiverse universe restricted
            deb http://archive.ubuntu.com/ubuntu <codename>-security main multiverse universe restricted


            If you want a command to do this:



            printf 'deb http://archive.ubuntu.com/ubuntu %s main multiverse universe restrictedn' $(lsb_release -sc){,-security} > /etc/apt/sources.list




            In addition to the Launchpad list, the list provided by the Software Sources program is
            from /usr/share/python-apt/templates/Ubuntu.mirrors, which is from the python-apt-common package. This package is only an indirect Suggests dependency of apt, so it may not be installed by default on a server.






            share|improve this answer























            • That's exactly what I wanted clarification on. Thank you!
              – Ryan Burnette
              Feb 18 '15 at 23:47










            • this answers perfectly for boths posts (the one linked and this one)
              – Brian Thomas
              Aug 16 '16 at 2:37










            • But you would still have to validate this answer with the documentation on the Ubuntu website itself as you cannot verify the intentions of the person providing this answer?
              – Herbert Van-Vliet
              Nov 24 at 11:43















            up vote
            17
            down vote



            accepted










            I'm not sure what you want, but:




            • The parent repository is always http://archive.ubuntu.com/ubuntu - everything else is a mirror of this. The other primary mirrors all have a domain of the form <cctld>.archive.ubuntu.com, where the two character short code is the Country Code Top Level Domain. You can find additional mirrors with their status at Launchpad.

            • The distribution codename is part of the channel (the third term). You can use lsb_release -sc to find that out, and it's the first word of the release pretty name in lowercase (trusty for Trusty Tahr, for example).

            • There are five channels: <codename>, <codename>-security, <codename>-updates, <codename>-backports and <codename>-proposed. The first is necessary as it is the base, the second is highly recommended as it contains security fixes, the fourth only if you need some package backported from a newer release and the fifth only if a developer asks you to enable it for testing a possible fix.

            • There are four repository sections: main, multiverse, universe and restricted (What's the difference between multiverse, universe, restricted and main?)


            So you can always create a safe sources.list which contains just:



            deb http://archive.ubuntu.com/ubuntu <codename> main multiverse universe restricted
            deb http://archive.ubuntu.com/ubuntu <codename>-security main multiverse universe restricted


            If you want a command to do this:



            printf 'deb http://archive.ubuntu.com/ubuntu %s main multiverse universe restrictedn' $(lsb_release -sc){,-security} > /etc/apt/sources.list




            In addition to the Launchpad list, the list provided by the Software Sources program is
            from /usr/share/python-apt/templates/Ubuntu.mirrors, which is from the python-apt-common package. This package is only an indirect Suggests dependency of apt, so it may not be installed by default on a server.






            share|improve this answer























            • That's exactly what I wanted clarification on. Thank you!
              – Ryan Burnette
              Feb 18 '15 at 23:47










            • this answers perfectly for boths posts (the one linked and this one)
              – Brian Thomas
              Aug 16 '16 at 2:37










            • But you would still have to validate this answer with the documentation on the Ubuntu website itself as you cannot verify the intentions of the person providing this answer?
              – Herbert Van-Vliet
              Nov 24 at 11:43













            up vote
            17
            down vote



            accepted







            up vote
            17
            down vote



            accepted






            I'm not sure what you want, but:




            • The parent repository is always http://archive.ubuntu.com/ubuntu - everything else is a mirror of this. The other primary mirrors all have a domain of the form <cctld>.archive.ubuntu.com, where the two character short code is the Country Code Top Level Domain. You can find additional mirrors with their status at Launchpad.

            • The distribution codename is part of the channel (the third term). You can use lsb_release -sc to find that out, and it's the first word of the release pretty name in lowercase (trusty for Trusty Tahr, for example).

            • There are five channels: <codename>, <codename>-security, <codename>-updates, <codename>-backports and <codename>-proposed. The first is necessary as it is the base, the second is highly recommended as it contains security fixes, the fourth only if you need some package backported from a newer release and the fifth only if a developer asks you to enable it for testing a possible fix.

            • There are four repository sections: main, multiverse, universe and restricted (What's the difference between multiverse, universe, restricted and main?)


            So you can always create a safe sources.list which contains just:



            deb http://archive.ubuntu.com/ubuntu <codename> main multiverse universe restricted
            deb http://archive.ubuntu.com/ubuntu <codename>-security main multiverse universe restricted


            If you want a command to do this:



            printf 'deb http://archive.ubuntu.com/ubuntu %s main multiverse universe restrictedn' $(lsb_release -sc){,-security} > /etc/apt/sources.list




            In addition to the Launchpad list, the list provided by the Software Sources program is
            from /usr/share/python-apt/templates/Ubuntu.mirrors, which is from the python-apt-common package. This package is only an indirect Suggests dependency of apt, so it may not be installed by default on a server.






            share|improve this answer














            I'm not sure what you want, but:




            • The parent repository is always http://archive.ubuntu.com/ubuntu - everything else is a mirror of this. The other primary mirrors all have a domain of the form <cctld>.archive.ubuntu.com, where the two character short code is the Country Code Top Level Domain. You can find additional mirrors with their status at Launchpad.

            • The distribution codename is part of the channel (the third term). You can use lsb_release -sc to find that out, and it's the first word of the release pretty name in lowercase (trusty for Trusty Tahr, for example).

            • There are five channels: <codename>, <codename>-security, <codename>-updates, <codename>-backports and <codename>-proposed. The first is necessary as it is the base, the second is highly recommended as it contains security fixes, the fourth only if you need some package backported from a newer release and the fifth only if a developer asks you to enable it for testing a possible fix.

            • There are four repository sections: main, multiverse, universe and restricted (What's the difference between multiverse, universe, restricted and main?)


            So you can always create a safe sources.list which contains just:



            deb http://archive.ubuntu.com/ubuntu <codename> main multiverse universe restricted
            deb http://archive.ubuntu.com/ubuntu <codename>-security main multiverse universe restricted


            If you want a command to do this:



            printf 'deb http://archive.ubuntu.com/ubuntu %s main multiverse universe restrictedn' $(lsb_release -sc){,-security} > /etc/apt/sources.list




            In addition to the Launchpad list, the list provided by the Software Sources program is
            from /usr/share/python-apt/templates/Ubuntu.mirrors, which is from the python-apt-common package. This package is only an indirect Suggests dependency of apt, so it may not be installed by default on a server.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 6 at 10:58

























            answered Feb 17 '15 at 18:20









            muru

            135k20289492




            135k20289492












            • That's exactly what I wanted clarification on. Thank you!
              – Ryan Burnette
              Feb 18 '15 at 23:47










            • this answers perfectly for boths posts (the one linked and this one)
              – Brian Thomas
              Aug 16 '16 at 2:37










            • But you would still have to validate this answer with the documentation on the Ubuntu website itself as you cannot verify the intentions of the person providing this answer?
              – Herbert Van-Vliet
              Nov 24 at 11:43


















            • That's exactly what I wanted clarification on. Thank you!
              – Ryan Burnette
              Feb 18 '15 at 23:47










            • this answers perfectly for boths posts (the one linked and this one)
              – Brian Thomas
              Aug 16 '16 at 2:37










            • But you would still have to validate this answer with the documentation on the Ubuntu website itself as you cannot verify the intentions of the person providing this answer?
              – Herbert Van-Vliet
              Nov 24 at 11:43
















            That's exactly what I wanted clarification on. Thank you!
            – Ryan Burnette
            Feb 18 '15 at 23:47




            That's exactly what I wanted clarification on. Thank you!
            – Ryan Burnette
            Feb 18 '15 at 23:47












            this answers perfectly for boths posts (the one linked and this one)
            – Brian Thomas
            Aug 16 '16 at 2:37




            this answers perfectly for boths posts (the one linked and this one)
            – Brian Thomas
            Aug 16 '16 at 2:37












            But you would still have to validate this answer with the documentation on the Ubuntu website itself as you cannot verify the intentions of the person providing this answer?
            – Herbert Van-Vliet
            Nov 24 at 11:43




            But you would still have to validate this answer with the documentation on the Ubuntu website itself as you cannot verify the intentions of the person providing this answer?
            – Herbert Van-Vliet
            Nov 24 at 11:43












            up vote
            6
            down vote













            If you understand what each line stands for in /etc/apt/sources.list, you can generate your own list. For example a line in my sources.list is,



            deb http://archive.ubuntu.com/ubuntu/ trusty main


            It has 4 sections:




            • Section 1: The first section is deb here which means it is a repository of all the binary packages. only other possible value is deb-src which means its a repository of source codes.

            • Section 2: This section contains the URI of the repository (http://us.archive.ubuntu.com/ubuntu/ in this case). The URI can vary for mirrors e.g. if you want to use the official US mirror then the URI will be http://us.archive.ubuntu.com/ubuntu/.

            • Section 3: It contains the codename (and channel name) of the release you are using, in this case trusty which is the codename of my Ubuntu release (14.04 LTS). you can find yours by lsb_release -sc. For example, If you are using 12.04 the codename will be "precise". Now to declare other channels e.g. to declare security channel you need to use trusty-security.


            • Section 4: This section contains "section names" of the repository. There are usually 4 section names used: main, restricted, universe, multiverse. You can put all the section names in the same line of declaring a repository or you can use different lines for each of the sections but there must not be any duplicate entry. If you read the /etc/apt/sources.list, then you will see the description of packages each of these sections contains.







            share|improve this answer



























              up vote
              6
              down vote













              If you understand what each line stands for in /etc/apt/sources.list, you can generate your own list. For example a line in my sources.list is,



              deb http://archive.ubuntu.com/ubuntu/ trusty main


              It has 4 sections:




              • Section 1: The first section is deb here which means it is a repository of all the binary packages. only other possible value is deb-src which means its a repository of source codes.

              • Section 2: This section contains the URI of the repository (http://us.archive.ubuntu.com/ubuntu/ in this case). The URI can vary for mirrors e.g. if you want to use the official US mirror then the URI will be http://us.archive.ubuntu.com/ubuntu/.

              • Section 3: It contains the codename (and channel name) of the release you are using, in this case trusty which is the codename of my Ubuntu release (14.04 LTS). you can find yours by lsb_release -sc. For example, If you are using 12.04 the codename will be "precise". Now to declare other channels e.g. to declare security channel you need to use trusty-security.


              • Section 4: This section contains "section names" of the repository. There are usually 4 section names used: main, restricted, universe, multiverse. You can put all the section names in the same line of declaring a repository or you can use different lines for each of the sections but there must not be any duplicate entry. If you read the /etc/apt/sources.list, then you will see the description of packages each of these sections contains.







              share|improve this answer

























                up vote
                6
                down vote










                up vote
                6
                down vote









                If you understand what each line stands for in /etc/apt/sources.list, you can generate your own list. For example a line in my sources.list is,



                deb http://archive.ubuntu.com/ubuntu/ trusty main


                It has 4 sections:




                • Section 1: The first section is deb here which means it is a repository of all the binary packages. only other possible value is deb-src which means its a repository of source codes.

                • Section 2: This section contains the URI of the repository (http://us.archive.ubuntu.com/ubuntu/ in this case). The URI can vary for mirrors e.g. if you want to use the official US mirror then the URI will be http://us.archive.ubuntu.com/ubuntu/.

                • Section 3: It contains the codename (and channel name) of the release you are using, in this case trusty which is the codename of my Ubuntu release (14.04 LTS). you can find yours by lsb_release -sc. For example, If you are using 12.04 the codename will be "precise". Now to declare other channels e.g. to declare security channel you need to use trusty-security.


                • Section 4: This section contains "section names" of the repository. There are usually 4 section names used: main, restricted, universe, multiverse. You can put all the section names in the same line of declaring a repository or you can use different lines for each of the sections but there must not be any duplicate entry. If you read the /etc/apt/sources.list, then you will see the description of packages each of these sections contains.







                share|improve this answer














                If you understand what each line stands for in /etc/apt/sources.list, you can generate your own list. For example a line in my sources.list is,



                deb http://archive.ubuntu.com/ubuntu/ trusty main


                It has 4 sections:




                • Section 1: The first section is deb here which means it is a repository of all the binary packages. only other possible value is deb-src which means its a repository of source codes.

                • Section 2: This section contains the URI of the repository (http://us.archive.ubuntu.com/ubuntu/ in this case). The URI can vary for mirrors e.g. if you want to use the official US mirror then the URI will be http://us.archive.ubuntu.com/ubuntu/.

                • Section 3: It contains the codename (and channel name) of the release you are using, in this case trusty which is the codename of my Ubuntu release (14.04 LTS). you can find yours by lsb_release -sc. For example, If you are using 12.04 the codename will be "precise". Now to declare other channels e.g. to declare security channel you need to use trusty-security.


                • Section 4: This section contains "section names" of the repository. There are usually 4 section names used: main, restricted, universe, multiverse. You can put all the section names in the same line of declaring a repository or you can use different lines for each of the sections but there must not be any duplicate entry. If you read the /etc/apt/sources.list, then you will see the description of packages each of these sections contains.








                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Feb 17 '15 at 18:37

























                answered Feb 17 '15 at 18:28









                heemayl

                65.7k8137210




                65.7k8137210






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f586595%2frestore-default-apt-repositories-in-sources-list-from-command-line%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Quarter-circle Tiles

                    build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

                    Mont Emei