如何编辑/恢复’sources.list’文件

如何恢复已崩溃的sources.list ,我无法进行任何软件更新。 当我点击更新图标时,我没有得到任何回复。 我尝试编辑sources.list文件,“vi”编辑器不起作用。 我试图在“软件更新程序”上输入以下行:

 deb http://deb.torproject.org/torproject.org trusty main deb-src http://deb.torproject.org/torproject.org trusty main 

如果你能帮助我,我将不胜感激; 我不擅长使用终端。

14.04上的默认sources.list文件:

 # deb http://be.archive.ubuntu.com:80/ubuntu/ trusty main restricted # deb http://be.archive.ubuntu.com:80/ubuntu/ trusty-updates main restricted # deb http://security.ubuntu.com/ubuntu trusty-security main restricted # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. deb http://be.archive.ubuntu.com:80/ubuntu/ trusty main restricted deb-src http://be.archive.ubuntu.com:80/ubuntu/ trusty main restricted ## Major bug fix updates produced after the final release of the ## distribution. deb http://be.archive.ubuntu.com:80/ubuntu/ trusty-updates main restricted deb-src http://be.archive.ubuntu.com:80/ubuntu/ trusty-updates main restricted ## NB 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://be.archive.ubuntu.com:80/ubuntu/ trusty universe deb-src http://be.archive.ubuntu.com:80/ubuntu/ trusty universe deb http://be.archive.ubuntu.com:80/ubuntu/ trusty-updates universe deb-src http://be.archive.ubuntu.com:80/ubuntu/ trusty-updates universe ## NB 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://be.archive.ubuntu.com:80/ubuntu/ trusty multiverse deb-src http://be.archive.ubuntu.com:80/ubuntu/ trusty multiverse deb http://be.archive.ubuntu.com:80/ubuntu/ trusty-updates multiverse deb-src http://be.archive.ubuntu.com:80/ubuntu/ trusty-updates multiverse ## NB 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://be.archive.ubuntu.com:80/ubuntu/ trusty-backports main restricted universe multiverse deb-src http://be.archive.ubuntu.com:80/ubuntu/ trusty-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu trusty-security main restricted deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted deb http://security.ubuntu.com/ubuntu trusty-security universe deb-src http://security.ubuntu.com/ubuntu trusty-security universe deb http://security.ubuntu.com/ubuntu trusty-security multiverse deb-src http://security.ubuntu.com/ubuntu trusty-security 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 trusty partner # deb-src http://archive.canonical.com/ubuntu trusty partner ## Uncomment the following two lines to add software from Ubuntu's ## 'extras' repository. ## This software is not part of Ubuntu, but is offered by third-party ## developers who want to ship their latest software. # deb http://extras.ubuntu.com/ubuntu trusty main # deb-src http://extras.ubuntu.com/ubuntu trusty main 

该文件的位置是: /etc/apt/source.list

您可以通过发出sudo vi /etc/apt/source.listsudo nano /etc/apt/source.list可能更容易)来编辑它。

如果要添加提到的那些存储库,则应将这些行添加到文件的底部:

 # Tor Project Repositories deb http://deb.torproject.org/torproject.org trusty main deb-src http://deb.torproject.org/torproject.org trusty main 

注意:

默认情况下,您可以在/etc/apt dir中找到名为sources.list.save的此文件的备份

所以你可以用它来恢复你丢失的那个。

 sudo cp /etc/apt/sources.list.save /etc/apt/sources.list 

否则,如果您没有此文件,可以访问此链接: http : //repogen.simplylinux.ch/输入您的信息,您将获得自定义sources.list文件对于默认的存储库集,您需要启用这些存储库。

  1. 所有的Ubuntu Branches存储库。
  2. 安全 – 重要的安全更新。
  3. 安全源存储库
  4. 更新 – 推荐的更新
  5. 更新源存储库

只需删除文件sources.list

 sudo rm /etc/apt/sources.list 

或者如果你不相信我,请备份。

 sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak 

之后

  1. 通过Unity Dash启动软件和更新
  2. 单击Canonical支持的免费和开源软件(主)复选框
  3. 输入您的密码
  4. 关闭对话框

你会有一个新文件