Ubuntu apt-get install 问题: Could not resolve 'cn.archive.ubuntu.com'

本文介绍了一种在Ubuntu环境下安装Ctags时遇到的域名解析错误问题及其解决方法。通过Ping测试发现域名可正常解析,并通过修改/etc/hosts文件及重启网络服务最终成功安装。

问题描述:

今天使用Ubuntu 安装Ctags 时,遇见以下问题:

sudo apt-get install ctags

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'exuberant-ctags' instead of 'ctags'
The following NEW packages will be installed:
  exuberant-ctags
0 upgraded, 1 newly installed, 0 to remove and 356 not upgraded.
Need to get 133 kB of archives.
After this operation, 308 kB of additional disk space will be used.
Err http://cn.archive.ubuntu.com/ubuntu/ saucy/main exuberant-ctags i386 1:5.9~svn20110310-6
  Could not resolve 'cn.archive.ubuntu.com'
Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/main/e/exuberant-ctags/exuberant-ctags_5.9~svn20110310-6_i386.deb  Could not resolve 'cn.archive.ubuntu.com'
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

解决方法:

从Error Message 上看来似乎是“cn.archive.ubuntu.com”域名解析出错。于是在Terminal 里Ping了一下这个域名,发现可以Ping 通。

ping cn.archive.ubuntu.com

PING mirror.neu.edu.cn (202.118.1.64) 56(84) bytes of data.
64 bytes from ftp2.neu.edu.cn (202.118.1.64): icmp_seq=1 ttl=45 time=86.3 ms
64 bytes from ftp2.neu.edu.cn (202.118.1.64): icmp_seq=2 ttl=45 time=100 ms
64 bytes from ftp2.neu.edu.cn (202.118.1.64): icmp_seq=3 ttl=45 time=86.8 ms

于是尝试通过修改 /etc/hosts 解决这个问题:

  1. vi /etc/hosts
  2. 在文件末尾加入 “202.118.1.64 cn.archive.ubuntu.com”。
  3. 运行 “#/etc/init.d/networking restart” 重启网络。
  4. 运行 “sudo apt-get install ctags” 重新安装Ctags,成功!!!
sudo apt install openssh-server在虚拟机终端运行显示Err:1 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 openssh-client amd64 1:7.6p1-4ubuntu0.7 Could not resolve 'us.archive.ubuntu.com' Ign:2 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 ncurses-term all 6.1-1ubuntu1.18.04.1 Err:3 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 openssh-sftp-server amd64 1:7.6p1-4ubuntu0.7 Could not resolve 'us.archive.ubuntu.com' Err:4 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 openssh-server amd64 1:7.6p1-4ubuntu0.7 Could not resolve 'us.archive.ubuntu.com' Ign:5 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 ssh-import-id all 5.7-0ubuntu1.1 Ign:2 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 ncurses-term all 6.1-1ubuntu1.18.04.1 Err:5 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 ssh-import-id all 5.7-0ubuntu1.1 Could not resolve 'us.archive.ubuntu.com' Ign:2 http://security.ubuntu.com/ubuntu bionic-updates/main amd64 ncurses-term all 6.1-1ubuntu1.18.04.1 Err:2 http://security.ubuntu.com/ubuntu bionic-updates/main amd64 ncurses-term all 6.1-1ubuntu1.18.04.1 Could not resolve 'us.archive.ubuntu.com' E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/o/openssh/openssh-client_7.6p1-4ubuntu0.7_amd64.deb Could not resolve 'us.archive.ubuntu.com' E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/n/ncurses/ncurses-term_6.1-1ubuntu1.18.04.1_all.deb Could not resolve 'us.archive.ubuntu.com' E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/o/openssh/openssh-sftp-server_7.6p1-4ubuntu0.7_amd64.deb Could not resolve 'us.archive.ubuntu.com' E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/o/openssh/openssh-server_7.6p1-4ubuntu0.7_amd64.deb Could not resolve 'us.archive.ubuntu.com' E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/s/ssh-import-id/ssh-import-id_5.7-0ubuntu1.1_all.deb Could not resolve 'us.archive.ubuntu.com' E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
09-11
Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done. Removing intermediate container abb03a1cb27a ---> 003b73213073 Step 9/23 : RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && apt-get install -y --no-install-recommends nodejs ---> Running in b2b9be787ba2 2025-11-07 04:46:56 - =============================================================================== DEPRECATION WARNING =============================================================================== Node.js 18.x is no longer actively supported! You will not receive security or critical stability updates for this version. You should migrate to a supported version of Node.js as soon as possible. Please see https://nodesource.com/products/distributions for details about which version may be appropriate for you. The NodeSource Node.js distributions site contains information both about supported versions of Node.js and N|Solid supported Linux distributions. To learn more about usage, see: https://nodesource.com/products/distributions =============================================================================== Continuing in 10 seconds ... 2025-11-07 04:47:06 - Installing pre-requisites WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease Hit:2 http://security.ubuntu.com/ubuntu bionic-security InRelease Hit:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease Hit:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease Reading package lists... Building dependency tree... Reading state information... 1 package can be upgraded. Run 'apt list --upgradable' to see it. WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Reading package lists... Building dependency tree... Reading state information... ca-certificates is already the newest version (20230311ubuntu0.18.04.1). curl is already the newest version (7.58.0-2ubuntu3.24). The following additional packages will be installed: gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server gpgsm pinentry-curses Suggested packages: parcimonie xloadimage dbus-user-session libpam-systemd pinentry-gnome3 scdaemon pinentry-doc The following NEW packages will be installed: apt-transport-https gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server gpgsm pinentry-curses 0 upgraded, 10 newly installed, 0 to remove and 1 not upgraded. Need to get 1552 kB of archives. After this operation, 4525 kB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 apt-transport-https all 1.6.17 [1692 B] Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gnupg-l10n all 2.2.4-1ubuntu1.6 [50.1 kB] Get:3 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gnupg-utils amd64 2.2.4-1ubuntu1.6 [128 kB] Get:4 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gpg amd64 2.2.4-1ubuntu1.6 [468 kB] Get:5 http://archive.ubuntu.com/ubuntu bionic/main amd64 pinentry-curses amd64 1.1.0-1 [35.8 kB] Get:6 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gpg-agent amd64 2.2.4-1ubuntu1.6 [227 kB] Get:7 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gpg-wks-client amd64 2.2.4-1ubuntu1.6 [91.8 kB] Get:8 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gpg-wks-server amd64 2.2.4-1ubuntu1.6 [85.0 kB] Get:9 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gpgsm amd64 2.2.4-1ubuntu1.6 [215 kB] Get:10 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gnupg amd64 2.2.4-1ubuntu1.6 [249 kB] debconf: delaying package configuration, since apt-utils is not installed Fetched 1552 kB in 3s (472 kB/s) Selecting previously unselected package apt-transport-https. (Reading database ... 26040 files and directories currently installed.) Preparing to unpack .../0-apt-transport-https_1.6.17_all.deb ... Unpacking apt-transport-https (1.6.17) ... Selecting previously unselected package gnupg-l10n. Preparing to unpack .../1-gnupg-l10n_2.2.4-1ubuntu1.6_all.deb ... Unpacking gnupg-l10n (2.2.4-1ubuntu1.6) ... Selecting previously unselected package gnupg-utils. Preparing to unpack .../2-gnupg-utils_2.2.4-1ubuntu1.6_amd64.deb ... Unpacking gnupg-utils (2.2.4-1ubuntu1.6) ... Selecting previously unselected package gpg. Preparing to unpack .../3-gpg_2.2.4-1ubuntu1.6_amd64.deb ... Unpacking gpg (2.2.4-1ubuntu1.6) ... Selecting previously unselected package pinentry-curses. Preparing to unpack .../4-pinentry-curses_1.1.0-1_amd64.deb ... Unpacking pinentry-curses (1.1.0-1) ... Selecting previously unselected package gpg-agent. Preparing to unpack .../5-gpg-agent_2.2.4-1ubuntu1.6_amd64.deb ... Unpacking gpg-agent (2.2.4-1ubuntu1.6) ... Selecting previously unselected package gpg-wks-client. Preparing to unpack .../6-gpg-wks-client_2.2.4-1ubuntu1.6_amd64.deb ... Unpacking gpg-wks-client (2.2.4-1ubuntu1.6) ... Selecting previously unselected package gpg-wks-server. Preparing to unpack .../7-gpg-wks-server_2.2.4-1ubuntu1.6_amd64.deb ... Unpacking gpg-wks-server (2.2.4-1ubuntu1.6) ... Selecting previously unselected package gpgsm. Preparing to unpack .../8-gpgsm_2.2.4-1ubuntu1.6_amd64.deb ... Unpacking gpgsm (2.2.4-1ubuntu1.6) ... Selecting previously unselected package gnupg. Preparing to unpack .../9-gnupg_2.2.4-1ubuntu1.6_amd64.deb ... Unpacking gnupg (2.2.4-1ubuntu1.6) ... Setting up apt-transport-https (1.6.17) ... Setting up gnupg-l10n (2.2.4-1ubuntu1.6) ... Setting up gpgsm (2.2.4-1ubuntu1.6) ... Setting up gnupg-utils (2.2.4-1ubuntu1.6) ... Setting up pinentry-curses (1.1.0-1) ... Setting up gpg (2.2.4-1ubuntu1.6) ... Setting up gpg-agent (2.2.4-1ubuntu1.6) ... Setting up gpg-wks-server (2.2.4-1ubuntu1.6) ... Setting up gpg-wks-client (2.2.4-1ubuntu1.6) ... Setting up gnupg (2.2.4-1ubuntu1.6) ... Processing triggers for man-db (2.8.3-2ubuntu0.1) ... WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease Hit:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease Hit:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease Get:5 https://deb.nodesource.com/node_18.x nodistro InRelease [12.1 kB] Get:6 https://deb.nodesource.com/node_18.x nodistro/main amd64 Packages [11.7 kB] Fetched 23.9 kB in 2s (13.3 kB/s) Reading package lists... Building dependency tree... Reading state information... 1 package can be upgraded. Run 'apt list --upgradable' to see it. 2025-11-07 04:47:18 - Repository configured successfully. 2025-11-07 04:47:18 - To install Node.js, run: apt install nodejs -y 2025-11-07 04:47:18 - You can use N|solid Runtime as a node.js alternative 2025-11-07 04:47:18 - To install N|solid Runtime, run: apt install nsolid -y Reading package lists... Building dependency tree... Reading state information... 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: nodejs : Depends: libc6 (>= 2.28) but 2.27-3ubuntu1.6 is to be installed E: Unable to correct problems, you have held broken packages. The command '/bin/sh -c curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && apt-get install -y --no-install-recommends nodejs' returned a non-zero code: 100
最新发布
11-08
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [102 kB] Get:2 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB] Get:3 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [3373 kB] Get:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [102 kB] Get:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [102 kB] Get:6 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [13.5 kB] Get:7 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [186 kB] Get:8 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1344 kB] Get:9 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [11.3 MB] Get:10 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [1637 kB] Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [2411 kB] Get:12 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [3786 kB] Get:13 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [1688 kB] Get:14 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [30.8 kB] Get:15 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [1728 kB] Get:16 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [20.6 kB] Get:17 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [64.0 kB] Get:18 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [23.8 kB] Fetched 28.2 MB in 6s (4979 kB/s) Reading package lists... Reading package lists... Building dependency tree... Reading state information... 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: npm : Depends: node-gyp (>= 0.10.9) but it is not going to be installed E: Unable to correct problems, you have held broken packages. The command '/bin/sh -c apt-get clean && apt-get update && apt-get install --yes --no-install-recommends --no-install-suggests build-essential net-tools inetutils-ping libncurses5-dev libdigest-crc-perl libpopt-dev xxd liblzo2-dev zlib1g-dev lib32z1 libssl-dev libglib2.0-dev libreadline-dev libjson-c-dev libxml2-dev libsqlite3-dev sqlite3 libuv1-dev libxslt1-dev libfcgi-dev libevent-dev libyajl-dev liburiparser-dev libwebsockets-dev locales lua5.1 liblua5.1-dev python python3 python3-dev python3-pip git git-lfs subversion autoconf automake pkg-config ccache cmake ninja-build clang-tools-6.0 bison flex gettext ca-certificates libtool patch vim unzip uuid-dev wget curl cpio bc gawk gdb valgrind diffstat chrpath texinfo ssh openssh-client openssh-server netbase quilt protobuf-c-compiler dropbear-bin openvswitch-switch tmux dirmngr lighttpd alien mlocate iproute2 dos2unix lsb-release rsync gdisk man pax moreutils npm sudo' returned a non-zero code: 100
11-08
Step 8/22 : RUN apt-get clean && apt-get update && apt-get install --yes --no-install-recommends --no-install-suggests build-essential npm sudo build-essential net-tools inetutils-ping libncurses5-dev libdigest-crc-perl libpopt-dev xxd liblzo2-dev zlib1g-dev lib32z1 libssl-dev libglib2.0-dev libreadline-dev libjson-c-dev libxml2-dev libsqlite3-dev sqlite3 libuv1-dev libxslt1-dev libfcgi-dev libevent-dev libyajl-dev liburiparser-dev libwebsockets-dev locales lua5.1 liblua5.1-dev python python3 python3-dev python3-pip git git-lfs subversion autoconf automake pkg-config ccache cmake ninja-build clang-tools-6.0 bison flex gettext ca-certificates libtool patch vim unzip uuid-dev wget curl cpio bc gawk gdb valgrind diffstat chrpath texinfo ssh openssh-client openssh-server netbase quilt protobuf-c-compiler dropbear-bin openvswitch-switch tmux dirmngr lighttpd alien mlocate iproute2 dos2unix lsb-release rsync gdisk man pax moreutils npm sudo ---> Running in e931d2dcd184 Get:1 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB] Get:2 http://security.ubuntu.com/ubuntu bionic-security InRelease [102 kB] Get:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [102 kB] Get:4 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [23.8 kB] Get:5 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [1688 kB] Get:6 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [102 kB] Get:7 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [11.3 MB] Get:8 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [186 kB] Get:9 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [13.5 kB] Get:10 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1344 kB] Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [1728 kB] Get:12 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [3786 kB] Get:13 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [2411 kB] Get:14 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [30.8 kB] Get:15 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [20.6 kB] Get:16 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [64.0 kB] Get:17 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [1637 kB] Get:18 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [3373 kB] Fetched 28.2 MB in 25s (1118 kB/s) Reading package lists... Reading package lists... Building dependency tree... Reading state information... 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: npm : Depends: node-gyp (>= 0.10.9) but it is not going to be installed E: Unable to correct problems, you have held broken packages. The command '/bin/sh -c apt-get clean && apt-get update && apt-get install --yes --no-install-recommends --no-install-suggests build-essential npm sudo build-essential net-tools inetutils-ping libncurses5-dev libdigest-crc-perl libpopt-dev xxd liblzo2-dev zlib1g-dev lib32z1 libssl-dev libglib2.0-dev libreadline-dev libjson-c-dev libxml2-dev libsqlite3-dev sqlite3 libuv1-dev libxslt1-dev libfcgi-dev libevent-dev libyajl-dev liburiparser-dev libwebsockets-dev locales lua5.1 liblua5.1-dev python python3 python3-dev python3-pip git git-lfs subversion autoconf automake pkg-config ccache cmake ninja-build clang-tools-6.0 bison flex gettext ca-certificates libtool patch vim unzip uuid-dev wget curl cpio bc gawk gdb valgrind diffstat chrpath texinfo ssh openssh-client openssh-server netbase quilt protobuf-c-compiler dropbear-bin openvswitch-switch tmux dirmngr lighttpd alien mlocate iproute2 dos2unix lsb-release rsync gdisk man pax moreutils npm sudo' returned a non-zero code: 100
11-08
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值