如何从 sources.list 中删除/编辑格式错误的行?

如何从 sources.list 中删除/编辑格式错误的行?

伙计们。我想在我的 Ubuntu 18.04 lts 上安装 virtualbox,但是当我运行sudo apt 更新我明白了: E:列表文件 /etc/apt/sources.list (组件) 中的条目 53 格式错误 E:无法读取源列表。

以下是该列表:

# deb cdrom:[Ubuntu 18.04 LTS _Bionic Beaver_ - Release amd64 (20180426)]/ bionic main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://lt.archive.ubuntu.com/ubuntu/ bionic main restricted
# deb-src http://lt.archive.ubuntu.com/ubuntu/ bionic main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://lt.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
# deb-src http://lt.archive.ubuntu.com/ubuntu/ bionic-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://lt.archive.ubuntu.com/ubuntu/ bionic universe
# deb-src http://lt.archive.ubuntu.com/ubuntu/ bionic universe
deb http://lt.archive.ubuntu.com/ubuntu/ bionic-updates universe
# deb-src http://lt.archive.ubuntu.com/ubuntu/ bionic-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://lt.archive.ubuntu.com/ubuntu/ bionic multiverse
# deb-src http://lt.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://lt.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
# deb-src http://lt.archive.ubuntu.com/ubuntu/ bionic-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://lt.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src http://lt.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner

deb http://security.ubuntu.com/ubuntu bionic-security main restricted
# deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
# deb-src http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
deb http://archive.canonical.com/ubuntu bionic multiverse
# deb-src http://archive.canonical.com/ubuntu bionic multiverse
deb http://archive.canonical.com/ubuntu multiverse
# deb-src http://archive.canonical.com/ubuntu multiverse
deb http://download.virtualbox.org/virtualbox/debian bionic contrib
# deb-src http://download.virtualbox.org/virtualbox/debian bionic contrib
# deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse

抱歉,我是 Ubuntu 新手,但我认为问题出在这个上 **deb http://archive.canonical.com/ubuntu multiverse**(??)

哪里可能存在问题?谢谢!

答案1

不正确的行如下:

deb http://archive.canonical.com/ubuntu multiverse

缺少 ubuntu 版本名称。

正确的做法是:

deb http://archive.canonical.com/ubuntu bionic multiverse

错误行上方两行已经存在,并且包含发布名称:bionic

您应该删除或注释掉#不正确的行,保存sources.list文件并运行:

sudo apt update

保存后即可。

编辑步骤:

  1. 打开终端并输入sudo nano /etc/apt/sources.list
  2. 输入您的用户密码以继续。
  3. 找到第 53 行 ( deb http://archive.canonical.com/ubuntu multiverse)。
  4. #在该行的开头添加一个空格。
  5. 该行现在应如下所示:# deb http://archive.canonical.com/ubuntu multiverse
  6. Ctrl-X并回答问题,使用Y和保存修改后的文件Enter
  7. 现在应该保存文件并关闭编辑器。运行sudo apt update系统以了解您所做的更改,然后就没问题了。

相关内容