apt-get update 异常 Temporary failure resolving

1.问题描述

需要重装一下vim,执行操作提示:

root@ubuntu-novotech-dev:~# apt-get install vim
错误:
Err:1 http://ports.ubuntu.com/ubuntu-ports xenial/main armhf vim-runtime all 2:7.4.1689-3ubuntu1
  Temporary failure resolving 'ports.ubuntu.com'
Err:2 http://ports.ubuntu.com/ubuntu-ports xenial/main armhf vim armhf 2:7.4.1689-3ubuntu1
  Temporary failure resolving 'ports.ubuntu.com'
E: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/pool/main/v/vim/vim-runtime_7.4.1689-3ubuntu1_all.deb  Temporary failure resolving 'ports.ubuntu.com'


E: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/pool/main/v/vim/vim_7.4.1689-3ubuntu1_armhf.deb  Temporary failure resolving 'ports.ubuntu.com'


E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

再执行apt-get update 还是提示错误

2. 解决办法

百度了下:

使用cat命令追加nameserver设置

cat  >> /etc/resolv.conf << EOF

>nameserver 8.8.8.8
>nameserver 8.8.4.4

>EOF

或 

echo nameserver 8.8.8.8 > /etc/resolv.conf还不知道如何换行。。。)

设置完毕查看:

cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 8.8.4.4

但是这种方法在我的开发板上不生效。。。。


设置网关

查了下PC机的ip,在板子上设置路由默认网关为PC同一个

 route add default gw 192.168.2.1 


接下来就可以安装软件了 。

3. 可能用到的命令如下

Linux Force DHCP client (dhclient) to renew ip address

Linux renew ip command
$ sudo dhclient -r //release ip 释放IP
$ sudo dhclient //获取IP


参考文章:http://www.cyberciti.biz/faq/how ... -client-ip-address/

Now obtain fresh IP:
$ sudo dhclient
There is no need to restart network service. Above command should work with any Linux distro such as RHEL, Fedora, CentOS, Ubuntu and others. On a related note you can also try out the following commands:
# ifdown eth0
# ifup eth0
# /etc/init.d/network restart

OR
# /etc/init.d/networking restart

  • 8
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
在Docker容器中运行bash-4.2# apt-get update && apt-get install vim -y命令时出现了: apt-get: command not found的错误。这是因为Docker容器默认没有安装apt-get命令。为了解决这个问题,你可以使用以下两种方法之一: 方法一:在Dockerfile中添加安装apt-get的步骤 你可以在Dockerfile文件中添加以下内容来安装apt-get命令: FROM ubuntu:20.04 RUN apt-get update && apt-get install -y apt-utils RUN apt-get install -y vim 这样在构建Docker镜像时,apt-get命令将会被安装并可用。 方法二:使用apk命令代替apt-get命令 如果你使用的是Alpine Linux作为基础镜像,那么可以使用以下命令来安装vim: RUN apk update && apk add vim 这是因为Alpine Linux使用的是apk包管理器而不是apt-get。 请注意,根据你的具体情况选择适合的方法。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [docker容器中 bash: vi: command not found,docker apt-get 异常 Temporary failure resolving](https://download.csdn.net/download/weixin_38610070/14031838)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [Docker 快速入门,安装数据库 Dockerfile使用 制作ubuntu-flask镜像](https://blog.csdn.net/m0_61634551/article/details/129079615)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [-bash-4.2#:vim: command not found解决办法](https://blog.csdn.net/weixin_42057187/article/details/125087284)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值