Ubuntu12.04使用apt-get出错——更新软件源

前端之家收集整理的这篇文章主要介绍了Ubuntu12.04使用apt-get出错——更新软件源前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

  本来打算在Ubuntu上用apt-get安装vsftpd(very secure ftp daemon,ftp服务器),于是输入如下命令:

# apt-get install vsftpd

  但是出现如下提示

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package vsftpd is not available,but is referred to by another package.
This may mean that the package is missing,has been obsoleted,or
is only available from another source
E: Package 'vsftpd' has no installation candidate

  大概就是说找不到 vsftpd,没有 vsftpd 的安装候选。找到相关的问题 http://askubuntu.com/questions/14685/what-does-package-package-has-no-installation-candidate-mean,应该是要 # apt-get update 一下。但是尴尬的事情又来了,update 出现如下错误

......
Reading package lists... Done
W: Failed to fetch http://hk.archive.ubuntu.com/ubuntu/dists/precise/InRelease  
W: Failed to fetch http://hk.archive.ubuntu.com/ubuntu/dists/precise-updates/InRelease  
W: Failed to fetch http://hk.archive.ubuntu.com/ubuntu/dists/precise-backports/InRelease  
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/InRelease  
W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/precise/InRelease  
W: Failed to fetch 
......
W: Some index files Failed to download. They have been ignored,or old ones used instead.

  于是我又查了关于“Failed to fetch”的相关问题,参考 http://askubuntu.com/questions/298177/a-failed-to-fetch-error-occurs-when-apt-get-update-is-run-how-do-i-fix-thishttp://www.jb51.cc/article/p-vguoxhjn-bh.html 。提到跟 DNS 配置有关,于是我做了相应修改后发现依然无效(我装的是 Ubuntu 12.04 Server)。
  然后我就开始尝试修改软件源了,我的 Ubuntu 没有图形界面,相关操作如下:
  1、保险起见,备份 Ubuntu12.04 源列表

# cp /etc/apt/sources.list /etc/apt/sources.list.backup

  2、修改源列表文件

# vi /etc/apt/sources.list

  3、把里面的列表替换成下面的列表
【163源】

deb http://mirrors.163.com/ubuntu/ precise main restricted
 deb-src http://mirrors.163.com/ubuntu/ precise main restricted
 deb http://mirrors.163.com/ubuntu/ precise-updates main restricted
 deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted
 deb http://mirrors.163.com/ubuntu/ precise universe
 deb-src http://mirrors.163.com/ubuntu/ precise universe
 deb http://mirrors.163.com/ubuntu/ precise-updates universe
 deb-src http://mirrors.163.com/ubuntu/ precise-updates universe
 deb http://mirrors.163.com/ubuntu/ precise multiverse
 deb-src http://mirrors.163.com/ubuntu/ precise multiverse
 deb http://mirrors.163.com/ubuntu/ precise-updates multiverse
 deb-src http://mirrors.163.com/ubuntu/ precise-updates multiverse
 deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
 deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
 deb http://mirrors.163.com/ubuntu/ precise-security main restricted
 deb-src http://mirrors.163.com/ubuntu/ precise-security main restricted
 deb http://mirrors.163.com/ubuntu/ precise-security universe
 deb-src http://mirrors.163.com/ubuntu/ precise-security universe
 deb http://mirrors.163.com/ubuntu/ precise-security multiverse
 deb-src http://mirrors.163.com/ubuntu/ precise-security multiverse
 deb http://extras.ubuntu.com/ubuntu precise main
 deb-src http://extras.ubuntu.com/ubuntu precise main

【sohu源】

deb http://mirrors.sohu.com/ubuntu/ precise main restricted
 deb-src http://mirrors.sohu.com/ubuntu/ precise main restricted
 deb http://mirrors.sohu.com/ubuntu/ precise-updates main restricted
 deb-src http://mirrors.sohu.com/ubuntu/ precise-updates main restricted
 deb http://mirrors.sohu.com/ubuntu/ precise universe
 deb-src http://mirrors.sohu.com/ubuntu/ precise universe
 deb http://mirrors.sohu.com/ubuntu/ precise-updates universe
 deb-src http://mirrors.sohu.com/ubuntu/ precise-updates universe
 deb http://mirrors.sohu.com/ubuntu/ precise multiverse
 deb-src http://mirrors.sohu.com/ubuntu/ precise multiverse
 deb http://mirrors.sohu.com/ubuntu/ precise-updates multiverse
 deb-src http://mirrors.sohu.com/ubuntu/ precise-updates multiverse
 deb http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
 deb-src http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
 deb http://mirrors.sohu.com/ubuntu/ precise-security main restricted
 deb-src http://mirrors.sohu.com/ubuntu/ precise-security main restricted
 deb http://mirrors.sohu.com/ubuntu/ precise-security universe
 deb-src http://mirrors.sohu.com/ubuntu/ precise-security universe
 deb http://mirrors.sohu.com/ubuntu/ precise-security multiverse
 deb-src http://mirrors.sohu.com/ubuntu/ precise-security multiverse
 deb http://extras.ubuntu.com/ubuntu precise main
 deb-src http://extras.ubuntu.com/ubuntu precise main

【ubuntu.cn99.com源】

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

【电子科技大学】

deb http://ubuntu.uestc.edu.cn/ubuntu/ precise main restricted universe multiverse
 deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse
 deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse
 deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-security main restricted universe multiverse
 deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse
 deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise main restricted universe multiverse
 deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse
 deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse
 deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-security main restricted universe multiverse
 deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse

【中国科技大学】

deb http://debian.ustc.edu.cn/ubuntu/ precise main restricted universe multiverse
 deb http://debian.ustc.edu.cn/ubuntu/ precise-backports restricted universe multiverse
 deb http://debian.ustc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse
 deb http://debian.ustc.edu.cn/ubuntu/ precise-security main restricted universe multiverse
 deb http://debian.ustc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse
 deb-src http://debian.ustc.edu.cn/ubuntu/ precise main restricted universe multiverse
 deb-src http://debian.ustc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse
 deb-src http://debian.ustc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse
 deb-src http://debian.ustc.edu.cn/ubuntu/ precise-security main restricted universe multiverse
 deb-src http://debian.ustc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse

【北京理工大学】

deb http://mirror.bjtu.edu.cn/ubuntu/ precise main multiverse restricted universe
 deb http://mirror.bjtu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe
 deb http://mirror.bjtu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe
 deb http://mirror.bjtu.edu.cn/ubuntu/ precise-security main multiverse restricted universe
 deb http://mirror.bjtu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe
 deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise main multiverse restricted universe
 deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe
 deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe
 deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-security main multiverse restricted universe
 deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe

  4、更新软件源

# apt-get update

  我使用的是163源,出现如下提示即更新成功:

......
Hit http://mirrors.163.com precise-security/main Translation-en
Hit http://mirrors.163.com precise-security/multiverse Translation-en
Hit http://mirrors.163.com precise-security/restricted Translation-en
Hit http://mirrors.163.com precise-security/universe Translation-en
Reading package lists... Done

  在 sources.list 文件中,我们看到很多“main,restricted,universe,multiverse”的字眼,这里顺便说一下它们的区别:

  • main —— 完全的自由软件。
  • restricted —— 不完全的自由软件。
  • universe —— ubuntu官方不提供支持与补丁,全靠社区支持
  • muitiverse —— 非自由软件,完全不提供支持和补丁。

以及 precise 的字眼,其实 precise 是 Ubuntu 12.04 的 Code name,更多 Code name 如下所示:

  • Ubuntu 4.10 (Warty Warthog)
  • Ubuntu 5.04 (Hoary Hedgehog)
  • Ubuntu 5.10 (Breezy Badger)
  • Ubuntu 6.06 LTS (Dapper Drake)
  • Ubuntu 6.10 (Edgy Eft)
  • Ubuntu 7.04 (Feisty Fawn)
  • Ubuntu 7.10 (Gutsy Gibbon)
  • Ubuntu 8.04 LTS (Hardy Heron)
  • Ubuntu 8.10 (Intrepid Ibex)
  • Ubuntu 9.04 (Jaunty Jackalope)
  • Ubuntu 9.10 (Karmic Koala)
  • Ubuntu 10.04 LTS (Lucid Lynx)
  • Ubuntu 10.10 (Maverick Meerkat)
  • Ubuntu 11.04 (Natty Narwhal)
  • Ubuntu 11.10 (Oneiric Ocelot)
  • Ubuntu 12.04 LTS (Precise Pangolin)
  • Ubuntu 12.10 (Quantal Quetzal)
  • Ubuntu 13.04 (Raring Ringtail)
  • Ubuntu 13.10 (Saucy Salamander)
  • Ubuntu 14.04 LTS (Trusty Tahr)
  • Ubuntu 14.10 (Utopic Unicorn)
  • Ubuntu 15.04 (Vivid Vervet)
  • Ubuntu 15.10 (Wily Werewolf)
  • Ubuntu 16.04 LTS (Xenial Xerus)

      那么,除了 apt-get update,我们平常还会看到 apt-get upgrade 以及 apt-get dist-upgrade,它们的区别是什么呢?查阅相关资料,有如下解释:
      An update should always be performed before an upgrade or dist-upgrade. upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded.
      也就是说:
      update 是同步 /etc/apt/sources.list 和 /etc/apt/sources.list.d 中列出的源的索引,这样才能获取到最新的软件包。
      upgrade 是升级已安装的所有软件包,升级之后的版本就是本地索引里的,因此,在执行 upgrade 之前一定要执行 update,这样才能是最新的。
      由于包与包之间存在各种依赖关系,upgrade只是简单的更新包,不管这些依赖,它不和添加包,或是删除包。而dist-upgrade可以根据依赖关系的变化,添加包,删除包。
      更详细说明可以参考:http://www.cnblogs.com/PlusHappy/p/5725145.html


  那么,回到我们最开始的目的——安装 ftp 服务器。
  当我们执行完 apt-get update 后,可以不执行 apt-get upgrade,直接执行 apt-get install vsftpd 即可。

原文链接:https://www.f2er.com/ubuntu/354827.html

猜你在找的Ubuntu相关文章