楚梵 發表於 2021-3-27 14:03:00

Ubuntu更换国内镜像源

<p>&nbsp;</p>
<h1>Ubuntu更换国内镜像源</h1>
<p>&nbsp;</p>
<h2>1.备份原系统中的镜像源</h2>
<p><strong>sudo cp /etc/apt/sources.list /etc/apt/sources.bak1</strong></p>
<p>#第一个参数时拷贝的文件路径和文件名称,第二个是拷贝到(粘贴)的文件路径和文件名</p>
<p>&nbsp;<span class="cnblogs_code"><span style="color: rgba(0, 0, 255, 1)">sudo</span> <span style="color: rgba(0, 0, 255, 1)">cp</span> /etc/apt/sources.list /etc/apt/sources.bak1</span>&nbsp;</p>
<p>&nbsp;</p>
<h2>2.更改镜像源文件的访问权限(增加写权限)</h2>
<p><strong>sudo chmod u+w /etc/apt/sources.list</strong></p>
<p><strong>&nbsp;<span class="cnblogs_code"><span style="color: rgba(0, 0, 255, 1)">sudo</span> <span style="color: rgba(0, 0, 255, 1)">chmod</span> u+<span style="color: rgba(0, 0, 255, 1)">w</span> /etc/apt/sources.list</span>&nbsp;</strong></p>
<p>&nbsp;</p>
<p>更改完成可以再恢复文件的访问权限。</p>
<p>清华镜像源:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/&nbsp;</p>
<p>&nbsp;</p>
<h2>3.更改镜像源内容</h2>
<div class="cnblogs_code"><img src="https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif" id="code_img_closed_e9da31a2-4f33-41ae-8a2b-c58a8fae3bb6" class="code_img_closed"><img src="https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif" id="code_img_opened_e9da31a2-4f33-41ae-8a2b-c58a8fae3bb6" class="code_img_opened" style="display: none">
<div id="cnblogs_code_open_e9da31a2-4f33-41ae-8a2b-c58a8fae3bb6" class="cnblogs_code_hide">
<pre>#方法 <span style="color: rgba(0, 0, 255, 1)">sudo</span> gedit /etc/apt/<span style="color: rgba(0, 0, 0, 1)">sources.list


#阿里源
#deb http:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse</span>
#deb http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse</span>
#deb http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse</span>
#deb http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse</span>
#deb http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse</span>
#deb-src http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse</span>
#deb-src http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse</span>
#deb-src http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse</span>
#deb-src http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse</span>
#deb-src http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse</span>
<span style="color: rgba(0, 0, 0, 1)">
#网易源
#deb http:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.163.com/ubuntu/ bionic main restricted universe multiverse</span>
#deb http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse</span>
#deb http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse</span>
#deb http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse</span>
#deb http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse</span>
#deb-src http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.163.com/ubuntu/ bionic main restricted universe multiverse</span>
#deb-src http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse</span>
#deb-src http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse</span>
#deb-src http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse</span>
#deb-src http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse</span>
<span style="color: rgba(0, 0, 0, 1)">
#清华源
#deb https:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse</span>
#deb-src https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse</span>
#deb https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse</span>
#deb-src https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse</span>
#deb https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse</span>
#deb-src https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse</span>
#deb https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse</span>
#deb-src https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse</span>
#deb https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse</span>
#deb-src https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse</span>
<span style="color: rgba(0, 0, 0, 1)">
##中科大源
deb https:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse</span>
deb-src https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse</span>
deb https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse</span>
deb-src https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse</span>
deb https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse</span>
deb-src https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse</span>
deb https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse</span>
deb-src https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse</span>
deb https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse</span>
deb-src https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse</span></pre>
</div>
<span class="cnblogs_code_collapse">sources.list</span></div>
<p>&nbsp;</p>
<h2>4.更新软件源列表</h2>
<p><strong>sudo apt-get update</strong><br>#这个命令,会访问源列表里的每个网址,并读取软件列表,然后保存在本地电脑。<br>我们在新立得软件包管理器里看到的软件列表,都是通过update命令更新的。</p>
<p>&nbsp;&nbsp;<span class="cnblogs_code"><span style="color: rgba(0, 0, 255, 1)">sudo</span> apt-get update</span>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>sudo apt-get upgrade</strong><br>#这个命令,会把本地已安装的软件,与刚下载的软件列表里对应软件进行对比,如果发现已安装的软件版本太低,<br>就会提示你更新。如果你的软件都是最新版本,会提示:<br>    升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。</p>
<p>&nbsp;&nbsp;<span class="cnblogs_code"><span style="color: rgba(0, 0, 255, 1)">sudo</span> apt-get upgrade</span>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>【参考1】https://blog.csdn.net/qq_21095573/article/details/99736630</p>
<p>&nbsp;</p><br><br>
来源:https://www.cnblogs.com/doitjust/p/14585644.html
頁: [1]
查看完整版本: Ubuntu更换国内镜像源