restore default repositories in ubuntu

How to Restore Default Repositories in Ubuntu

APT (Advanced Package Tool) is a popular package management tool for Debian/Ubuntu systems. It allows you to easily install, upgrade, delete, and manage packages in Ubuntu systems. It uses a list of online repositories for this purpose contained in file named sources.list. These repositories contain copies of software installation files. This list is updated whenever you update/upgrade your Ubuntu system. Some software installation also require you to modify sources.list file. During this process, it is possible that it becomes corrupted due to wrong entries in it. If that happens, you will be unable to install or update software using package managers. To fix this, it is advisable to restore default repositories in Ubuntu. In this article, we will learn how to restore default repositories in Ubuntu.


How to Restore Default Repositories in Ubuntu

Here are the steps to restore default repositories in Ubuntu.

First, move your present sources.list file to another location using mv command.

$ sudo mv /etc/apt/sources.list ~/

Next, recreate the sources.list file using touch, vi, nano or any other command.

$ sudo touch /etc/apt/sources.list

Open Software & Updates

$ software-properties-gtk

It will open software properties gtk with no repository selected. Change main server to any other server of your choice. Also enable some repositories from the window so that it creates sources.list in /etc/apt folder.

Next, switch to updates tab and select one or more update channels. At least, select security and updates channels.

Of course, you can also download and install default sources.list for your Ubuntu distribution from internet using curl or wget commands.

There are also many third-party online tools to generate sources.lst file for Ubuntu systems. In this case, simply open the new sources.list file you created earlier and copy+paste the contents from the newly generated file. Save and close the file.

Run the following commands to update APT utility.

$ sudo apt-get update

This will update your sources.list with the latest file’s information.

In this article, we have learnt how to restore default repositories in Ubuntu. It is advisable to make a backup of sources.list in case you ever need to make manual updates to it, since it can lead to unexpected issues.

Also read:

How to Get Unique IP Address from Log
How to Merge JS Objects
How to Restrict Internet Access for Programs in Linux
How to Check if String is Valid Number in JavaScript
How to Detect Invalid Date in JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *