Tutorial

How to restore default repositories in Ubuntu?

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!

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products


About the authors

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel