Как восстановить репозитории по умолчанию в Ubuntu
APT (Advanced Package Tool) — это популярный инструмент управления пакетами для систем Debian/Ubuntu. Он позволяет легко устанавливать, обновлять, удалять и управлять пакетами в системах Ubuntu. Для этого он использует список онлайн-репозиториев, содержащийся в файле sources.list. Эти репозитории содержат копии установочных файлов программного обеспечения. Этот список обновляется каждый раз, когда вы обновляете/обновляете свою систему Ubuntu. При установке некоторых программ также требуется изменить файл sources.list. Во время этого процесса возможно, что он будет поврежден из-за неправильных записей в нем.
Если это произойдет, вы не сможете установить или обновить программное обеспечение с помощью менеджеров пакетов. Чтобы исправить это, рекомендуется восстановить репозитории по умолчанию в Ubuntu. В этой статье мы узнаем, как восстановить репозитории по умолчанию в Ubuntu.
Как восстановить репозитории по умолчанию в Ubuntu
Перед восстановлением, убедитесь что утилита software-properties-gtk установлена в вашей системе

Ниже описаны шаги по восстановлению репозиториев по умолчанию в Ubuntu.
Во-первых, переместите текущий файл sources.list в другое место с помощью команды mv.
Затем заново создайте файл sources.list с помощью команд touch, vi, nano или любой другой.
Откройте программное обеспечение и обновления
Откроются свойства ПО gtk без выбранного репозитория. Измените основной сервер на любой другой по вашему выбору. Также включите некоторые репозитории из окна, чтобы создать sources.list в папке /etc/apt.

Далее переключитесь на вкладку updates и выберите один или несколько каналов обновления. По крайней мере, выберите каналы безопасности и обновлений.
How to Restore Default Repositories in Ubuntu
Ubuntu has four standard repositories where software packages are stored: Main, Universe, Restricted, and Multiverse.
- Main: Free and Open Source Software supported by Canonical.
- Universe: Community maintained Free and Open Source Software.
- Restricted: Software that is not totally free.
- Multiverse: Non-free software.
Out of these four, ‘Main’ is enabled by default, and ‘Restricted’ can be enabled by the user during installation. ‘Universe’ and ‘Multiverse’ can be enabled from the ‘Softwares and Updates’ tool, or by directly modifying the source file (‘/etc/apt/sources.list’) for apt.
If your source file has been broken or corrupted, no apt command can run, and you will not be able to install or upgrade any software.
Let’s see how to restore default repositories in such a case.
Restoring Default Ubuntu Repositories
First, go to the directory where the source file is located.

View Ubuntu Source File
Now, backup the broken source file. For this, simply rename the file in the same directory.

Backup Ubuntu Source File
Now create an empty source file with the original name.
Now, click on the left top corner of your desktop, search for ‘Software and Updates‘ and open it.

Search Software and Updates
Enable ‘Main‘ by clicking on the checkboxes in front of the respective items. You can also similarly enable ‘Restricted‘, ‘Universe‘ and ‘Multiverse‘, should you wish to do so. Enter a password when prompted.

Enable Ubuntu Repositories
Close the window. Click on ‘Reload‘ when prompted, to fetch the package list from the repositories.

Install Software Updates
Go back to the terminal. Open the ‘sources.list‘ file again and verify if ‘Main‘ and ‘Restricted‘ repositories have been added.

Verify Ubuntu Repositories
Finally, verify if ‘apt update‘ runs properly.

Verify Ubuntu System Update
Conclusion
In this article, we saw how to restore the source file for apt, i.e., the list of repositories, back to default.
It is always a good idea to keep a backup of the original source file, before changing anything manually in it. This way, if anything stops working after the change, you can always restore the backup file and run a quick ‘apt update’ to get the apt working again.
If you have any questions or feedback, let us know in the comments below!
Как восстановить стандартные репозитории Ubuntu
У вас возникла ошибка при обновлении системных репозиториев или установке нового программного обеспечения? Такое случается, если поврежден файл /etc/apt/source.list, который содержит информацию о репозиториях. В этой статье мы покажем, как восстановить репозитории по умолчанию в Ubuntu.
В системе Ubuntu есть четыре стандартных вида репозиториев:
- Main
- Universe
- Restricted
- Multiverse
Восстановление репозиториев по умолчанию в Ubuntu
Во-первых, нам нужно сделать резервную копию поврежденного исходного файла, переместив его в другое место. Откройте терминал, нажав Ctrl+Alt+T, и введите следующую команду, чтобы перейти в каталог, в котором находится исходный файл:

Теперь переместите поврежденный файл в другое место:
sudo mv sources.list
sudo mv sources.list /sid/home/Desktop

Создайте новый файл при помощи команды:
sudo touch /etc/apt/sources.list

Теперь откройте приложение Software & Updates с помощью поиска или панели приложений. Перейдите на основной сервер и включите restricted репозиторий. Вы также можете включить репозитории universe и multiverse , если это необходимо.

Чтобы включить обновления, откройте вкладку Updates и в раскрывающемся меню Subscribed выберите All updates или, по крайней мере, обновления security , а затем закройте окно.

Нажмите на кнопку Reload. После этого программные репозитории будут обновлены.

Проверка репозиториев
ЧТобы убедиться, что репозитории были восстановлены, откройте терминал, нажав Ctrl+Alt+T. Затем откройте файл /etc/apt/sources.list, запустив эту команду:
sudo vi /etc/apt/sources.list

Если в файле есть записи без #, как показано на картинке ниже, значит, репозитории были добавлены верно.
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:
- Main
- Universe
- Restricted
- 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:

Now, move the corrupted file to other location:

Create a new file using the touch command:

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.

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.

Click on Reload. The software repositories will be updated.

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:

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

Finally, Update the repositories by executing the following command:

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.