How to restore default Ubuntu repositories?

In this article, we cover how to restore default Ubuntu repositories. Without repositories, we have to download packages and then install them manually. But, through repositories, we get to install packages with ease. And not only that, when updates are available. All we have to do is, update the repository and install the upgrades in one go.

All the repository related is stored in the file:

/etc/apt/sources.list

or, in the directory (containing *.list files):

/etc/apt/sources.list.d/

Furthermore, we can also use third-party repositories as well. But, we have to be extremely cautious when we do that. The package that we wish to install should come from trusted sources.

Note: Following operations require Administrative Rights. If you don’t have the required rights then, contact your System Administrator for assistance.

How to restore default Ubuntu repositories?

So, we have added quite a number of third-party repositories. Or, we have made changes to the sources.list file which has rendered the sources.list unusable.

In those circumstances, we have to restore sources.list to the default configuration. It is advisable to have a backup of the configuration that we wish to modify. In this case, it was sources.list and we should have a backup file. If there isn’t then we have to use Software & Updates application.

If, for some reason, it isn’t there then install it through the following commands:

sudo apt update
sudo apt install software-properties-gtk

Just before we launch the application. Take a backup of the existing sources.list file:

sudo cp /etc/apt/sources.list /home/$USER/Documents

and, delete the source sources.list config:

sudo rm /etc/apt/sources.list

Next, create empty sources.list file through touch command-line utility:

sudo touch /etc/apt/sources.list

Thereafter, launch Sofware & Updates application. Under the Ubuntu Software tab, click on checkboxes for repositories (i.e. main, universe, restricted, and multiverse). And, then go to the Updates tab and Subscribe to All Updates. Lastly, click on the Close button.

Once we have done that, use the following command to update the repositories:

sudo apt update

In conclusion, we have covered how to restore default Ubuntu repositories here.

Similar Posts