// Tutorial //

How to restore default repositories in Ubuntu?

Published on August 3, 2022
Default avatar
By ninad
Developer and author at DigitalOcean.
How to restore default repositories in Ubuntu?

While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.

Getting errors while updating system repositories or installing new software? You may get errors because your /etc/apt/source.list file is corrupted which contains the repositories details. In this article, We will see how to restore the default repositories in Ubuntu.

There are four standard repositories in Ubuntu:

  1. Main
  2. Universe
  3. Restricted
  4. Multiverse

Restore default repositories in Ubuntu

First, We need to back up the corrupted source file by moving it to another location. Open a terminal by pressing Ctrl+Alt+T and enter the following command to change the directory to where the source file is located:

cd /etc/apt

restore-default-repo-1

Now, move the corrupted file to other location:

sudo mv sources.list <location>
sudo mv sources.list /sid/home/Desktop

restore-default-repo-2

Create a new file using the touch command:

sudo touch /etc/apt/sources.list

restore-default-repo-3

Now, Open the Software & Updates application using the search bar or the app drawer. Change the server to the main server and enable the restriced repository. You can also enable universe and multiverse repositories if needed.

restore-default-repo-4

To enable the updates, Under the Updates tab, select All updates or at least security updates in Subscribed to drop-down menu and click on close.

restore-default-repo-5

Click on Reload. The software repositories will be updated.

restore-default-repo-6

Verify if repositories has been added

To verify, open a terminal by pressing Ctrl+Alt+T. Open the /etc/apt/sources.list file by running the following command:

sudo vi /etc/apt/sources.list

restore-default-repo-7

If there are entries without the # as shown below, the repositories has been added.

restore-default-repo-8

Finally, Update the repositories by executing the following command:

sudo apt update

restore-default-repo-9

Conclusion

So, We learned how to restore default repositories in Ubuntu. Follow Journaldev.com for even more tutorials on Linux, Python and more!


Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.

Sign up
About the authors
Default avatar
ninad

author

Developer and author at DigitalOcean.

Still looking for an answer?

Was this helpful?