个人工具

“UbuntuHelp:Repositories/CommandLine/zh”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
更多的了解
 
(未显示5个用户的7个中间版本)
第8行: 第8行:
 
Ubuntu 用[http://www.debian.org/doc/user-manuals#apt-howto apt] 包进行管理. Apt在文件中存储了一系列知识注解或软件信道<br>
 
Ubuntu 用[http://www.debian.org/doc/user-manuals#apt-howto apt] 包进行管理. Apt在文件中存储了一系列知识注解或软件信道<br>
 
<pre>/etc/apt/sources.list</pre>  
 
<pre>/etc/apt/sources.list</pre>  
在命令行编辑这些文件,我们可以添加, 移动, 活临时使软件的知识注解无效. https://help.ubuntu.com/community/IconsPage?action=AttachFile&amp;do=get&amp;target=eyes.png '''注意:''' 在编辑它们之前备份一个配置文件是一个好的编辑方式如 '''sources.list''' . 为做到这些,键入以下命令:
+
在命令行编辑这些文件,我们可以添加, 移动, 或临时使软件的知识注解无效. https://help.ubuntu.com/community/IconsPage?action=AttachFile&amp;do=get&amp;target=eyes.png '''注意:''' 在编辑它们之前备份一个配置文件是一个好的编辑方式如 '''sources.list''' . 为做到这些,键入以下命令:
 
<pre>sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
 
<pre>sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
 
</pre>  
 
</pre>  
第30行: 第30行:
  
 
* 每一方都由一个或两个hashes (#) 开始注解 andapt 或它的 front-ends apt-get, Synaptic, 没有准备好于 Adept.
 
* 每一方都由一个或两个hashes (#) 开始注解 andapt 或它的 front-ends apt-get, Synaptic, 没有准备好于 Adept.
 +
以#开头的是注释,也就是不能被apt-get 和他的前端新立得使用的的
 
* 在没有hashes的这一行是 ''apt的注解行''. 首先两个 apt 行在我们的例子中如下<br>
 
* 在没有hashes的这一行是 ''apt的注解行''. 首先两个 apt 行在我们的例子中如下<br>
 +
没有#号开头的就是能够使用的。
 
<pre>deb http://archive.ubuntu.com/ubuntu dapper main restricted
 
<pre>deb http://archive.ubuntu.com/ubuntu dapper main restricted
 
deb-src http://archive.ubuntu.com/ubuntu dapper main restricted
 
deb-src http://archive.ubuntu.com/ubuntu dapper main restricted
 
</pre>  
 
</pre>  
* Here's what they say:
+
* 他们所述如下:
* '''deb''': 这些注解包过二进制活前期编译包。许多的用户需要这些注解。<br>
+
* '''deb''': 这些存储库包过二进制前期编译包。许多的用户需要这些存储库。<br>
* '''deb-src''': 这些注解包过包中的源代码。对开发者是很有帮助的。<br>
+
* '''deb-src''': 这些存储库包过包中的源代码。对开发者是很有帮助的。<br>
 
* '''http://archive.ubuntu.com/ubuntu''': URI (Uniform Resource Identifier),在这种情况下英特网上的地址. 参照 [https://launchpad.net/ubuntu/+archivemirrors official mirror list] 或者到自我修复 [[UbuntuWiki:Archive|mirror list]] 来寻找别的映像.
 
* '''http://archive.ubuntu.com/ubuntu''': URI (Uniform Resource Identifier),在这种情况下英特网上的地址. 参照 [https://launchpad.net/ubuntu/+archivemirrors official mirror list] 或者到自我修复 [[UbuntuWiki:Archive|mirror list]] 来寻找别的映像.
 
* '''dapper''' 是在你的分类中发布你的名字或版本。<br>
 
* '''dapper''' 是在你的分类中发布你的名字或版本。<br>
第71行: 第73行:
 
=== 添加其他的存储库<br> ===
 
=== 添加其他的存储库<br> ===
  
https://help.ubuntu.com/community/IconsPage?action=AttachFile&amp;do=get&amp;target=warning.png '''注意:''' 有一些(不是通常情况下)原因使你想添加一些非Ubuntu的存储库到你的软件源的中 .由于在一些国家对专利和执照的限制使得一些软件不能被Ubuntu发布(例如 [[UbuntuHelp:RestrictedFormats|RestrictedFormats]] 页).你可能想添加一些存储库来支持这些软件. 确保你用这种方式加入的'''所有'''存储库都被Ubuntu系统测试和了解其能在Ubuntu系统中工作. 存储库没有被设计与你的Ubuntu版本工作的话可能导致它在你的系统中不兼容甚至可能迫使你重装。
+
https://help.ubuntu.com/community/IconsPage?action=AttachFile&amp;do=get&amp;target=warning.png '''注意:''' 有一些(不是通常情况下)原因使你想添加一些非Ubuntu的存储库到你的软件源中 .由于在一些国家对专利和执照的限制使得一些软件不能被Ubuntu发布(例如 [[UbuntuHelp:RestrictedFormats|RestrictedFormats]] 页).你可能想添加一些存储库来支持这些软件. 确保你用这种方式加入的'''所有'''存储库都被Ubuntu系统测试和了解其能在Ubuntu系统中工作. 存储库没有被设计与你的Ubuntu版本工作的话可能导致它在你的系统中不兼容甚至可能迫使你重装。
  
 
----
 
----
第86行: 第88行:
 
=== 使存储库能够于一个(非交互的)文本Enabling Repositories with a (non-interactive) Script ===
 
=== 使存储库能够于一个(非交互的)文本Enabling Repositories with a (non-interactive) Script ===
  
https://help.ubuntu.com/community/IconsPage?action=AttachFile&amp;do=get&amp;target=eyes.png This section is directed at advanced users. '''问题:''' 在不需要任何输入的情况下You are looking for a way to enable the extra repositories without any user input. <br> '''例如:''' 你可以为应用程序构造一个自定义安装文本,但这个文本需要从普通和多元存储库中获取软件包. <br> 接下来的就是一个简单的文本是What follows is a simple script that enables the extra repositories that are commented out on a 默认安装Ubuntu 6.06 LTS.
+
https://help.ubuntu.com/community/IconsPage?action=AttachFile&amp;do=get&amp;target=eyes.png 对于优秀的使用者这个部分有指导作用. '''问题:''' 在不需要使用者输入的情况下找到这个特殊的存储库. '''例如:''' 你可以为应用程序构造一个自定义安装文本,但这个文本需要从普通和多元存储库中获取软件包. 接下来的就是一个简单的文本命令是使得这个特殊的存储库可以被默认安装Ubuntu 6.06 LTS识别.
  
 
* 首先,保存你原来的sources.list 文件.
 
* 首先,保存你原来的sources.list 文件.
 
<pre>sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig
 
<pre>sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig
 
</pre>  
 
</pre>  
* 现在Now make the changes to uncomment all respositories listed in the sources.list file.
+
* 现在Now make the changes to uncomment 所有的存储库 respositories listed in the sources.list文件.
 
<pre>sudo sed -i -e "s/# deb/deb/g" /etc/apt/sources.list
 
<pre>sudo sed -i -e "s/# deb/deb/g" /etc/apt/sources.list
 
</pre>  
 
</pre>  
第107行: 第109行:
 
* Remember to retrieve updated package lists by issuing a '''sudo apt-get update''' when you're done editing '''sources.list'''.
 
* Remember to retrieve updated package lists by issuing a '''sudo apt-get update''' when you're done editing '''sources.list'''.
  
=== Further Reading ===
+
=== 更多的了解<br> ===
 +
 
 
* [http://www.debian.org/doc/manuals/apt-howto/index.en.html The Debian Apt User Manual]
 
* [http://www.debian.org/doc/manuals/apt-howto/index.en.html The Debian Apt User Manual]
* [[UbuntuHelp:AptGetHowto|Apt-get]]  
+
* [[UbuntuHelp:AptGetHowto|Apt-get]]
 
* [[UbuntuHelp:SoftwareManagement|Software Management]]
 
* [[UbuntuHelp:SoftwareManagement|Software Management]]
 
* [http://wiki.debian.org/SecureApt Secure Apt] on the Debian Wiki
 
* [http://wiki.debian.org/SecureApt Secure Apt] on the Debian Wiki
  
[[category:UbuntuHelp]]
+
[[Category:UbuntuHelp]]
 +
[[Category:包管理]]

2010年4月5日 (一) 20:14的最新版本

IconsPage?action=AttachFile&do=get&target=terminal.png This page describes how to manage software repositories from the command line. This is useful if you prefer not to use (or are unable to access) a graphical user interface. Also, it may come in handy as it works uniformly across all versions of Ubuntu. IconsPage?action=AttachFile&do=get&target=eyes.png The instructions on this page assume that you are comfortable using a text editor like GEdit or nano. Using the graphical interface to manage software repositories is recommended, see [[UbuntuHelp:../Ubuntu|Managing Repositories in Ubuntu]] or [[UbuntuHelp:../Kubuntu|Kubuntu]] instead.

背景信息

Ubuntu 用apt 包进行管理. Apt在文件中存储了一系列知识注解或软件信道

/etc/apt/sources.list

在命令行编辑这些文件,我们可以添加, 移动, 或临时使软件的知识注解无效. IconsPage?action=AttachFile&do=get&target=eyes.png 注意: 在编辑它们之前备份一个配置文件是一个好的编辑方式如 sources.list . 为做到这些,键入以下命令:

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


一般来说 ,/etc/apt/sources.list 文件包含的信息如下所示:

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

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

# deb http://archive.ubuntu.com/ubuntu dapper universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu dapper universe multiverse

# deb http://archive.ubuntu.com/ubuntu dapper-backports main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu dapper-backports main restricted universe multiverse 
# deb http://security.ubuntu.com/ubuntu breezy-security main restricted
# deb-src http://security.ubuntu.com/ubuntu breezy-security main restricted

解说知识仓库的结构

  • 每一方都由一个或两个hashes (#) 开始注解 andapt 或它的 front-ends apt-get, Synaptic, 没有准备好于 Adept.

以#开头的是注释,也就是不能被apt-get 和他的前端新立得使用的的

  • 在没有hashes的这一行是 apt的注解行. 首先两个 apt 行在我们的例子中如下

没有#号开头的就是能够使用的。

deb http://archive.ubuntu.com/ubuntu dapper main restricted
deb-src http://archive.ubuntu.com/ubuntu dapper main restricted
  • 他们所述如下:
  • deb: 这些存储库包过二进制前期编译包。许多的用户需要这些存储库。
  • deb-src: 这些存储库包过包中的源代码。对开发者是很有帮助的。
  • http://archive.ubuntu.com/ubuntu: URI (Uniform Resource Identifier),在这种情况下英特网上的地址. 参照 official mirror list 或者到自我修复 mirror list 来寻找别的映像.
  • dapper 是在你的分类中发布你的名字或版本。
  • main & restricted 都是一个部分的名字 或者 what components. 这些按位置来分类可以用几个段名。

添加领域和多元的注解

添加软件的注解如 <a href="What Universe and Multiverse">什么是领域和多元</a> 可以不注释相应的apt行 (如 删除 '#' 在起始行). 在我们的例子中,我们不注释以下行:

deb http://archive.ubuntu.com/ubuntu dapper universe multiverse
deb-src http://archive.ubuntu.com/ubuntu dapper universe multiverse

然而,如果安全稳定和升级被将被主群组和限制 and updates are enabled for Main and Restricted, 我们要添加一下行来确保我们能够对我们的领域和多元包的升级 (在安装和升级包的时候不要做太多改变导致版本的错配):

deb http://archive.ubuntu.com/ubuntu dapper-security universe multiverse
deb-src http://archive.ubuntu.com/ubuntu dapper-security universe multiverse
deb http://archive.ubuntu.com/ubuntu dapper-updates universe multiverse
deb-src http://archive.ubuntu.com/ubuntu dapper-updates universe multiverse

IconsPage?action=AttachFile&do=get&target=eyes.png 如果你只想要普通包而不是多元包,就从命令行中删除所有的含有'multiverse' 的命令行.只要你满意你自己的选择就将你修改后的文件保存。现在,用一下命令从新的添加注解中重置升级包:

sudo apt-get update

Done! 你的系统已经准备好安装领域和多元的注解包了。

添加商业存储库 

Feisty (7.04) 现在是一个商业软件领域的存储库. 你可以添加以下行在你的 /etc/apt/sources.list 文件中:

deb http://archive.canonical.com/ubuntu feisty-commercial main

接下来用和以前一样命令升级:

sudo apt-get update

确定包含在这个存储库中的软件代码不是开源代码。

添加其他的存储库

IconsPage?action=AttachFile&do=get&target=warning.png 注意: 有一些(不是通常情况下)原因使你想添加一些非Ubuntu的存储库到你的软件源中 .由于在一些国家对专利和执照的限制使得一些软件不能被Ubuntu发布(例如 RestrictedFormats 页).你可能想添加一些存储库来支持这些软件. 确保你用这种方式加入的所有存储库都被Ubuntu系统测试和了解其能在Ubuntu系统中工作. 存储库没有被设计与你的Ubuntu版本工作的话可能导致它在你的系统中不兼容甚至可能迫使你重装。


  • 你可以在你的软件源中使用apt存储库命令在你的软件源添加自定义软件库You can add custom software repositories by adding the apt repository line of your software source to the list of repositories. 如下所示:
deb http://mirror3.ubuntulinux.nl/ dapper-seveas freenx
  • 在你的 sources.list 的最后添加这一指令行并保存该文件.
  • 下一步,使用如下的命令使apt识别到新的软件存储库:
sudo apt-get update
  • 完成了! 这个新的软件库现在应该能够使用了.

使存储库能够于一个(非交互的)文本Enabling Repositories with a (non-interactive) Script

IconsPage?action=AttachFile&do=get&target=eyes.png 对于优秀的使用者这个部分有指导作用. 问题: 在不需要使用者输入的情况下找到这个特殊的存储库. 例如: 你可以为应用程序构造一个自定义安装文本,但这个文本需要从普通和多元存储库中获取软件包. 接下来的就是一个简单的文本命令是使得这个特殊的存储库可以被默认安装Ubuntu 6.06 LTS识别.

  • 首先,保存你原来的sources.list 文件.
sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig
  • 现在Now make the changes to uncomment 所有的存储库 respositories listed in the sources.list文件.
sudo sed -i -e "s/# deb/deb/g" /etc/apt/sources.list
  • 用如下的命令让apt联系到新的软件存储库:
sudo apt-get update
  • 完成了! 这个新的软件存储库现在就可以被使用了.

提议与建议

  • 在理开始编辑之前备份你的配置文件总是非常有用的, 如 /etc/apt/sources.list. You can then revert your changes if needed. 如果出现了严重的错误, head over to http://www.ubuntulinux.nl/source-o-matic 这个页面会构造一个新的sources.list文件给你.
  • 如果你决定If you decide to add other repositories to sources.list, make sure that the repository is meant to work (and known to work) with Ubuntu. Repositories that are not designed to work with your version of Ubuntu can introduce inconsistencies in your system and might force you to re-install. Also, make sure that you really need to add external repositories as the software package(s) you are looking for may already have been introduced into the official repositories!
  • Please keep in mind that it may not be legal to enable some non-Ubuntu software repositories in some countries.
  • You may be asked enter a security key when adding a non-Ubuntu repository to your sources. See Managing Authentication Keys for instructions.
  • Remember to retrieve updated package lists by issuing a sudo apt-get update when you're done editing sources.list.

更多的了解