cat /etc/apt/sources.list 的正确输出是什么?

cat /etc/apt/sources.list 的正确输出是什么?

我有 Ubuntu 12.04 LTS。我需要正确的输出,因为我编辑了它,因为它不起作用,但它只会让情况变得更糟。

答案1

您可以通过运行以下命令在 Ubuntu 22.04 及更高版本中使用 heredoc 重新创建标准 sources.list。

sudo cp /etc/apt/sources.list /etc/apt/backup.txt 
cat <<EOF | sudo tee /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs) main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-backports main universe restricted multiverse
EOF

您还可以将新的标准 sources.list 写入名为 BACKUP.txt 的新备份文件,而无需/etc/apt/sources.list使用这样的 heredoc 更改现有文件。

cat <<EOF >> ~/Desktop/BACKUP.txt
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs) main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-backports main universe restricted multiverse
EOF

以下是/etc/apt/sources.listUbuntu 22.04 标准文件的一个简单示例:

deb http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse  
deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu jammy-security main restricted universe multiverse

自 Ubuntu 20.10 以来,合作伙伴存储库一直为空。

编辑 sources.list 文件的最简单方法是从 nano 编辑器中的终端使用以下命令:

sudo nano /etc/apt/sources.list  

使用 nano 的说明始终显示在页面底部。使用键盘组合Ctrl+ O,然后按Enter将文件保存到当前位置。使用键盘组合Ctrl+X退出 nano。

确保在更改 sources.list 后运行此命令以刷新可用软件列表。

sudo apt update  

Ubuntu 20.04 的标准 sources.list 文件如下所示:

deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse  
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse  
deb http://archive.canonical.com/ubuntu focal partner

Ubuntu 18.04 的标准 sources.list 文件如下所示:

deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse  
deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse  
deb http://archive.canonical.com/ubuntu bionic partner

Ubuntu 16.04 的标准 sources.list 文件如下所示:

deb http://archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse  
deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu xenial-security main restricted universe multiverse  
deb http://archive.canonical.com/ubuntu xenial partner

Ubuntu 14.04 的标准 sources.list 文件如下所示:

deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse  
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse  
deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu trusty-security main restricted universe multiverse  
deb http://archive.canonical.com/ubuntu trusty partner

Ubuntu 12.04 的标准 sources.list 文件如下所示:

deb http://archive.ubuntu.com/ubuntu precise main universe restricted multiverse
deb http://archive.ubuntu.com/ubuntu precise-updates universe main multiverse restricted
deb http://archive.ubuntu.com/ubuntu precise-backports universe main multiverse restricted
deb http://archive.ubuntu.com/ubuntu precise-security universe main multiverse restricted

答案2

我知道现在回答这个问题已经很晚了,但是由于(作为新手)我花了超过 24 小时来解决此问题,因此我发现此链接非常有用。它包含 ubuntu 文件的所有默认内容: https://repogen.simplylinux.ch/

实际上,该站点从用户那里获取有关他们的 Linux 发行版和他们想要的文件的名称的信息,然后提供文件的默认内容作为输出,我们可以复制和使用。

相关内容