帮助文档
专业提供香港服务器、香港云服务器、香港高防服务器租用、香港云主机、台湾服务器、美国服务器、美国云服务器vps租用、韩国高防服务器租用、新加坡服务器、日本服务器租用 一站式全球网络解决方案提供商!专业运营维护IDC数据中心,提供高质量的服务器托管,服务器机房租用,服务器机柜租用,IDC机房机柜租用等服务,稳定、安全、高性能的云端计算服务,实时满足您的多样性业务需求。 香港大带宽稳定可靠,高级工程师提供基于服务器硬件、操作系统、网络、应用环境、安全的免费技术支持。
服务器资讯 / 香港服务器租用 / 香港VPS租用 / 香港云服务器 / 美国服务器租用 / 台湾服务器租用 / 日本服务器租用 / 官方公告 / 帮助文档
ubuntu设定apt-get源
发布时间:2024-03-03 03:58:45   分类:帮助文档
ubuntu设定apt-get源




一、更新为本地源
备份 备份/etc/apt/sources.list cp /etc/apt/sources.list /etc/apt/sources.list.bak

在/etc/apt/sources.list文件前面添加如下条目 #添加阿里源 deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
最后执行如下命令更新源 更新 sudo apt-get update sudo apt-get upgrade
二、sudo apt-get update报错
Get:1 http://mirrors.aliyun.com/ubuntu bionic InRelease [242 kB] Get:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease [88.7 kB] Get:3 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease [88.7 kB] Err:1 http://mirrors.aliyun.com/ubuntu bionic InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32 Get:4 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease [242 kB] Get:5 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease [83.3 kB] Err:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32 Err:3 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32 Err:4 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32 Err:5 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32 Reading package lists... Done W: GPG error: http://mirrors.aliyun.com/ubuntu bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32 E: The repository 'http://mirrors.aliyun.com/ubuntu bionic InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. W: GPG error: http://mirrors.aliyun.com/ubuntu bionic-security InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32 E: The repository 'http://mirrors.aliyun.com/ubuntu bionic-security InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. W: GPG error: http://mirrors.aliyun.com/ubuntu bionic-updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32 E: The repository 'http://mirrors.aliyun.com/ubuntu bionic-updates InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. W: GPG error: http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32 E: The repository 'http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. W: GPG error: http://mirrors.aliyun.com/ubuntu bionic-backports InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32 E: The repository 'http://mirrors.aliyun.com/ubuntu bionic-backports InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. 分析: 更换源之后需要添加公钥,执行以下命令: 注意:这里的recv-keys就是报错中的key,粘贴过来即可 W: GPG error: http://mirrors.aliyun.com/ubuntu bionic-backports InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32 即执行如下操作: gpg --keyserver keyserver.ubuntu.com --recv-keys 公钥 gpg --export --armor 公钥 | sudo apt-key add - 针对本文问题,则执行: gpg --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 gpg --export --armor 3B4FE6ACC0B21F32 | sudo apt-key add -
三、更新
升级 & 安装 apt-get update // 更新源文件,并不会做任何安装升级操作 apt-get upgrade // 升级所有已安装的包 apt-get install packagename // 安装指定的包 apt-get install packagename --only-upgrade // 仅升级指定的包 apt-get install packagename --reinstall // 重新安装包 apt-get -f install // 修复安装 apt-get build-dep packagename // 安装相关的编译环境 apt-get source packagename // 下载该包的源代码 apt-get dist-upgrade // 升级系统 apt-get dselect-upgrade // 使用 dselect 升级 查询 & 显示 apt-cache search packagename // 查询指定的包    apt-cache show packagename // 显示包的相关信息,如说明、大小、版本等 apt-cache depends packagename // 了解使用该包依赖哪些包 apt-cache rdepends packagename // 查看该包被哪些包依赖 删除 apt-get remove packagename // 删除包    apt-get remove packagename -- purge // 删除包,包括删除配置文件等 apt-get autoremove packagename --purge // 删除包及其依赖的软件包+配置文件等(只对6.10有效,推荐使用) 清理和检查 apt-get clean // 清理无用的包 apt-get autoclean // 清理无用的包 apt-get check // 检查是否有损坏的依赖
三、安装g++问题
`fresher@DESKTOP-EIF33SC:~$ sudo apt install g++ Reading package lists… Done Building dependency tree… Done Reading state information… Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:
The following packages have unmet dependencies: libc6-dev : Depends: libc6 (= 2.27-3ubuntu1.6) but 2.35-0ubuntu3.1 is to be installed Depends: libc-dev-bin (= 2.27-3ubuntu1.6) but it is not going to be installed E: Unable to correct problems, you have held broken packages.` 以上问题,经调查,是因为/etc/apt/sources.list中设定的源和Ubuntu的版本不对应导致的。解决办法如下: ubuntu的版本源是有规律的。要查版本号可以通过lsb_release -a查看自己系统上的版本号。 然后可判断出上面的阿里源配置的是Ubuntu 18.04。而Ubuntu 22.04的代号是jammy。将/etc/apt/sources.list文件中的“bionic”替换成“jammy”即可。




香港云服务器租用推荐
服务器租用资讯
·广东云服务有限公司怎么样
·广东云服务器怎么样
·广东锐讯网络有限公司怎么样
·广东佛山的蜗牛怎么那么大
·广东单位电话主机号怎么填写
·管家婆 花生壳怎么用
·官网域名过期要怎么办
·官网邮箱一般怎么命名
·官网网站被篡改怎么办
服务器租用推荐
·美国服务器租用
·台湾服务器租用
·香港云服务器租用
·香港裸金属服务器
·香港高防服务器租用
·香港服务器租用特价