如何恢复sources.list 文件?

Oxw*_*ivi 14 software-sources

我不小心删除了我的/etc/apt/sources.list文件。它是否由 Canonical 托管在某个地方,以便我可以将其重新添加到系统中?这有点紧急,所以我希望有人能提供一个快速的答案。

Lek*_*eyn 10

您可以启动到 Live CD(虚拟机就足够了)并/etc/apt/sources.list从中复制。或者,准备好 Live CD 映像并按照以下说明操作:

  1. 挂载 CD。如果您有一个.iso文件,请使用以下命令挂载它:

    sudo mount -o loop ubuntu-11.04-desktop-amd64.iso /media/cdrom
    
    Run Code Online (Sandbox Code Playgroud)
  2. 从 CD 挂载文件系统文件:

    sudo mount -o loop /media/cdrom/casper/filesystem.squashfs /mnt
    
    Run Code Online (Sandbox Code Playgroud)
  3. 复制 sources.list 文件:

    sudo cp {/mnt,}/etc/apt/sources.list
    
    Run Code Online (Sandbox Code Playgroud)
  4. 如有必要,更改文件权限:

    sudo chmod 644 /etc/apt/sources.list
    
    Run Code Online (Sandbox Code Playgroud)

从我的 Ubuntu 11.04 Live CD:

deb http://archive.ubuntu.com/ubuntu natty main restricted
deb-src http://archive.ubuntu.com/ubuntu natty main restricted

deb http://security.ubuntu.com/ubuntu natty-security main restricted
deb-src http://security.ubuntu.com/ubuntu natty-security main restricted

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

## Uncomment the following two lines to add software from the 'universe'
## repository.
## 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://archive.ubuntu.com/ubuntu natty universe
# deb-src http://archive.ubuntu.com/ubuntu natty universe
# deb http://archive.ubuntu.com/ubuntu natty-updates universe
# deb-src http://archive.ubuntu.com/ubuntu natty-updates universe
# deb http://security.ubuntu.com/ubuntu natty-security universe
# deb-src http://security.ubuntu.com/ubuntu natty-security 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://archive.ubuntu.com/ubuntu natty multiverse
# deb-src http://archive.ubuntu.com/ubuntu natty multiverse
# deb http://archive.ubuntu.com/ubuntu natty-updates multiverse
# deb-src http://archive.ubuntu.com/ubuntu natty-updates multiverse
# deb http://security.ubuntu.com/ubuntu natty-security multiverse
# deb-src http://security.ubuntu.com/ubuntu natty-security multiverse
Run Code Online (Sandbox Code Playgroud)

为获得最佳下载速度,您需要重新选择您附近的镜像:

  1. 打开 Ubuntu 软件中心
  2. 打开编辑->软件源...
  3. 单击“下载自”旁边的选择框
  4. 选择您选择的服务器

您可能还想启用一些存储库,例如社区维护的开源软件 (universe)受版权和法律问题限制的软件 (multiverse)