解决Ubuntu报错: 在源列表 /etc/apt/sources.list 中第 14 行有误 (类型)

遇到问题:在修改sources.list时候关闭时无法保存,显示过"/etc.apt/sources.list" E212: 无法打开并写入文件

原因:镜像源出问题

第一步:查看当前Ubuntu版本

lsb_release -a

会出现如下:

 

得知Ubuntu版本为18.04.1 LTS

第二步: 在阿里云镜像源当中找到对应版本的镜像源阿里巴巴开源镜像站-OPSX镜像站-阿里云开发者社区 (aliyun.com)

例如18.04.1 LTS的镜像为:

deb https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

将原来sources.list里面的内容删除(按D),然后将这段内容复制进去,并保存退出

第三步:更新镜像源

sudo apt update

就解决了! 

  • 16
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
这个错误通常是由于软件列表文件的语法错误导致的。要解决这个问题,您可以尝试以下几种方法: 1. 检查列表文件:使用文本编辑器打开 /etc/apt/sources.list.d/docker.list 文件,确保该文件的内容正确且没有任何语法错误。确认第一包含 "deb" 字样,并且没有任何拼写错误或格式问题。 2. 重置列表文件:如果您不确定如何编辑列表文件,可以尝试将其重置为默认值。首先备份当前的列表文件,然后创建一个新的空白文件。在终端以下命令: ``` sudo cp /etc/apt/sources.list.d/docker.list /etc/apt/sources.list.d/docker.list.bak sudo echo "" > /etc/apt/sources.list.d/docker.list ``` 这将备份当前的文件,并创建一个新的空白文件。然后您可以尝试重新配置软件列表。 3. 使用软件管理工具:如果您对手动编辑软件列表文件不太熟悉,您可以使用软件管理工具来帮助您。在Ubuntu系统,可以使用命令工具 `software-properties-gtk` 或 `software-properties-kde` 来管理软件。您可以在终端以下命令来安装其一个工具: ``` sudo apt-get update sudo apt-get install software-properties-gtk # For GNOME desktop sudo apt-get install software-properties-kde # For KDE desktop ``` 安装完成后,您可以使用这些工具来添加、删除或更改软件,而无需手动编辑文件。 无论您选择哪种方法,请确保在更改软件列表后运 `sudo apt-get update` 命令来更新软件包列表。这将使系统使用新的软件更新和安装操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值