Ubuntu 24.04 apt 更换国内镜像站源
login65536 2024-06-24 08:37:02 阅读 74
Ubuntu 24.04 LTS 后的source.list
24.04LTS 后,apt源的位置替换到了/etc/apt/sources.list.d/ubuntu.sources
中
/etc/apt/sources.list# Ubuntu sources have moved to the /etc/apt/sources.list.d/ubuntu.sources# file, which uses the deb822 format. Use deb822-formatted .sources files# to manage package sources in the /etc/apt/sources.list.d/ directory.# See the sources.list(5) manual page for details.
同时,格式改变,现在为DEB822
格式,详见这里
现在的格式是这样的
/etc/apt/sources.list.d/ubuntu.sources## /etc/cloud/templates/sources.list.ubuntu.deb822.tmpl### See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to# newer versions of the distribution.## Ubuntu distribution repository#### The following settings can be adjusted to configure which packages to use from Ubuntu.## Mirror your choices (except for URIs and Suites) in the security section below to## ensure timely security updates.#### Types: Append deb-src to enable the fetching of source package.## URIs: A URL to the repository (you may add multiple URLs)## Suites: The following additional suites can be configured## <name>-updates - Major bug fix updates produced after the final release of the## distribution.## <name>-backports - software from this repository may not have been tested as## extensively as that contained in the main release, although it includes## newer versions of some applications which may provide useful features.## Also, please note that software in backports WILL NOT receive any review## or updates from the Ubuntu security team.## Components: Aside from main, the following components can be added to the list## restricted - Software that may not be under a free license, or protected by patents.## universe - Community maintained packages.## Software from this repository is only maintained and supported by Canonical## for machines with Ubuntu Pro subscriptions. Without Ubuntu Pro, the Ubuntu## community provides best-effort security maintenance.## multiverse - Community maintained of restricted. Software from this repository is## ENTIRELY UNSUPPORTED by the Ubuntu team, and may not be under a free## licence. Please satisfy yourself as to your rights to use the software.## Also, please note that software in multiverse WILL NOT receive any## review or updates from the Ubuntu security team.#### See the sources.list(5) manual page for further settings.Types: debURIs: http://archive.ubuntu.com/ubuntuSuites: noble noble-updates noble-backportsComponents: main universe restricted multiverseSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg## Ubuntu security updates. Aside from URIs and Suites,## this should mirror your choices in the previous section.Types: debURIs: http://security.ubuntu.com/ubuntuSuites: noble-securityComponents: main universe restricted multiverseSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
因此,如果要使用国内诸如清华TUNA源,USTC源,也需要使用新格式
具体方法
sources.list.d
文件夹中,所有.sources
拓展名结尾的文件均会被作为一个可选的源
因此我们将原始文件备份:
sudo mv /etc/apt/sources.list.d/ubuntu.sources /etc/apt/backup-sources.list.d-ubuntu.sources
然后创建一个新的文件,以.sources
结尾,例如
sudo vim /etc/apt/sources.list.d/tuna.sources
里面填入
Types: debURIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/#如果使用其他镜像站,上面这行可以改成其他镜像站的网址Suites: noble noble-updates noble-backportsComponents: main universe restricted multiverseSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpgTypes: debURIs: http://security.ubuntu.com/ubuntu#如果安全更新需要使用镜像站,上面这行也改成 URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/Suites: noble-securityComponents: main universe restricted multiverseSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
之后运行
$ sudo apt update$ sudo apt upgrade
声明
本文内容仅代表作者观点,或转载于其他网站,本站不以此文作为商业用途
如有涉及侵权,请联系本站进行删除
转载本站原创文章,请注明来源及作者。