After following these commands from https://askubuntu.com/a/159371/63298, it removed my sources.list and when I do sudo apt-get upgrade, it's asking me to auto-remove the packages lost.

How do I revert my source.list from the source.list.backup? Now my source.list.d is a directory and not a list.

3 Answers 3


With four commands:

sudo apt-add-repository main
sudo apt-add-repository universe
sudo apt-add-repository multiverse
sudo apt-add-repository restricted

Or move or copy your backup

sudo cp /etc/apt/source.list.backup /etc/apt/source.list

The folder /etc/apt/source.list.d has always been a folder, a sub-folder of /etc/apt. After the removal of /etc/apt/source.list, the folder /etc/apt usually contains only this folder.


The sources.list can be generated in multiple ways. The GUI provided in ubuntu basically generates that file (it is in Settings -> Software). There is /usr/share/doc/apt/examples/sources.list which is in all the proper format. You can copy the example file to original file, cp /usr/share/doc/apt/examples/sources.list /etc/apt/sources.list And there is also online generator https://repogen.simplylinux.ch/

But your file should remain in /etc/apt directory. You can revert changes with sudo mv /etc/apt/sources.list.backup /etc/apt/sources.list


I managed to restore if after https://askubuntu.com/a/159371/63298 by:

sudo cp /etc/apt/source.list.backup /etc/apt/source.list
sudo apt-get update
sudo apt-get upgrade

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.