How to Fix Repository Errors While Running apt update on Ubuntu Linux with 3 Methods (Hindi)

Опубликовано: 25 Октябрь 2024
на канале: ProgrammingKnowledge Hindi
7,252
57

Solution 1: Revert to the Original Ubuntu Mirror
If you bump into this error, the first trick up your sleeve is to switch back to the original mirror. This involves creating a new sources list file from the sample source list file in /usr/share/doc/apt/examples/sources.list path.

You can have a peek at the sample source list file as shown:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ cat /usr/share/doc/apt/examples/sources.list
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__________________________________________________________________________
Sample Output
See sources.list(5) manpage for more information
|# Remember that CD-ROMs, DVDs and such are managed through the apt cdrom tool.
deb http://us.archive.ubuntu.com/ubuntu focal main restricted
deb-src http://us.archive.ubuntu.com/ubuntu focal main restricted
deb http://security.ubuntu.com/ubuntu focal-security main restricted
deb-src http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://us.archive.ubuntu.com/ubuntu focal-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu focal-updates main restricted
-----------------------------------------------------------------------------------------------------------------------------
But first, as is always recommended, make a backup copy of the sources lists as shown:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ sudo mv /etc/apt/sources.list{,.backup}
$ sudo mv /etc/apt/sources.list.d{,.backup}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Next, create a new sources list file from the sample sources list file by following the steps below:
~~~~~~~~~~~~~~~~~~~~~~~~~
$ sudo mkdir /etc/apt/sources.list.d
$ sudo cp /usr/share/doc/apt/examples/sources.list /etc/apt/sources.list
Finally, update the repositories as shown.
$ sudo apt update
~~~~~~~~~~~~~~~~~~~~~~~~~~
This restores all the mirrors and enables the ‘Main‘ repository which is supported by Canonical.
To install community-supported software packages, proprietary packages, and packages not available under a completely free license, you might consider enabling the following repositories:
• Universe – Community-maintained free and open-source software.
• Restricted – Proprietary drivers for devices.
• Multiverse – Software restricted by copyright or legal issues.
To enable these repositories, invoke the commands below.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ sudo add-apt-repository restricted
$ sudo add-apt-repository multiverse
$ sudo add-apt-repository universe
Then update your package lists.
$ sudo apt update
~~~~~~~~~~~~~~~~~~~~~~~~~~~
At this point, you should have both the Main repository and community-supported repositories at your disposal.
Solution 2: Select the Nearest Mirror from Official Ubuntu Mirrors
Alternatively, you might consider switching to the nearest mirror – which often happens to be the fastest mirror – relative to your geographical location.
The easiest approach is to ensure that the mirror defined within the sources list file includes the country code relative to your country of residence. For example, the Official United States mirror provided in /etc/apt/sources.list is:
**********************************************************************
deb http://us.archive.ubuntu.com/ubuntu focal main restricted
**********************************************************************
If your location is not in the United States, just overwrite the US country code with the appropriate country code. For instance, if you are located in Canada, replace us with ca as shown in the file as shown.
****************************************************************
deb http://ca.archive.ubuntu.com/ubuntu focal main restricted
****************************************************************
Once done, update the sources list as shown:
~~~~~~~~~~~~~~~~~~~~~~
$ sudo apt update
~~~~~~~~~~~~~~~~~~~~~~