特殊:Badtitle/NS100:Repositories/CommandLine
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/Repositories/CommandLine }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/af | • {{#if: UbuntuHelp:Repositories/CommandLine|Afrikaans| [[::Repositories/CommandLine/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/ar | • {{#if: UbuntuHelp:Repositories/CommandLine|العربية| [[::Repositories/CommandLine/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/az | • {{#if: UbuntuHelp:Repositories/CommandLine|azərbaycanca| [[::Repositories/CommandLine/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/bcc | • {{#if: UbuntuHelp:Repositories/CommandLine|جهلسری بلوچی| [[::Repositories/CommandLine/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/bg | • {{#if: UbuntuHelp:Repositories/CommandLine|български| [[::Repositories/CommandLine/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/br | • {{#if: UbuntuHelp:Repositories/CommandLine|brezhoneg| [[::Repositories/CommandLine/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/ca | • {{#if: UbuntuHelp:Repositories/CommandLine|català| [[::Repositories/CommandLine/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/cs | • {{#if: UbuntuHelp:Repositories/CommandLine|čeština| [[::Repositories/CommandLine/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/de | • {{#if: UbuntuHelp:Repositories/CommandLine|Deutsch| [[::Repositories/CommandLine/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/el | • {{#if: UbuntuHelp:Repositories/CommandLine|Ελληνικά| [[::Repositories/CommandLine/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/es | • {{#if: UbuntuHelp:Repositories/CommandLine|español| [[::Repositories/CommandLine/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/fa | • {{#if: UbuntuHelp:Repositories/CommandLine|فارسی| [[::Repositories/CommandLine/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/fi | • {{#if: UbuntuHelp:Repositories/CommandLine|suomi| [[::Repositories/CommandLine/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/fr | • {{#if: UbuntuHelp:Repositories/CommandLine|français| [[::Repositories/CommandLine/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/gu | • {{#if: UbuntuHelp:Repositories/CommandLine|ગુજરાતી| [[::Repositories/CommandLine/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/he | • {{#if: UbuntuHelp:Repositories/CommandLine|עברית| [[::Repositories/CommandLine/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/hu | • {{#if: UbuntuHelp:Repositories/CommandLine|magyar| [[::Repositories/CommandLine/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/id | • {{#if: UbuntuHelp:Repositories/CommandLine|Bahasa Indonesia| [[::Repositories/CommandLine/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/it | • {{#if: UbuntuHelp:Repositories/CommandLine|italiano| [[::Repositories/CommandLine/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/ja | • {{#if: UbuntuHelp:Repositories/CommandLine|日本語| [[::Repositories/CommandLine/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/ko | • {{#if: UbuntuHelp:Repositories/CommandLine|한국어| [[::Repositories/CommandLine/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/ksh | • {{#if: UbuntuHelp:Repositories/CommandLine|Ripoarisch| [[::Repositories/CommandLine/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/mr | • {{#if: UbuntuHelp:Repositories/CommandLine|मराठी| [[::Repositories/CommandLine/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/ms | • {{#if: UbuntuHelp:Repositories/CommandLine|Bahasa Melayu| [[::Repositories/CommandLine/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/nl | • {{#if: UbuntuHelp:Repositories/CommandLine|Nederlands| [[::Repositories/CommandLine/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/no | • {{#if: UbuntuHelp:Repositories/CommandLine|norsk| [[::Repositories/CommandLine/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/oc | • {{#if: UbuntuHelp:Repositories/CommandLine|occitan| [[::Repositories/CommandLine/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/pl | • {{#if: UbuntuHelp:Repositories/CommandLine|polski| [[::Repositories/CommandLine/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/pt | • {{#if: UbuntuHelp:Repositories/CommandLine|português| [[::Repositories/CommandLine/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/ro | • {{#if: UbuntuHelp:Repositories/CommandLine|română| [[::Repositories/CommandLine/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/ru | • {{#if: UbuntuHelp:Repositories/CommandLine|русский| [[::Repositories/CommandLine/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/si | • {{#if: UbuntuHelp:Repositories/CommandLine|සිංහල| [[::Repositories/CommandLine/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/sq | • {{#if: UbuntuHelp:Repositories/CommandLine|shqip| [[::Repositories/CommandLine/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/sr | • {{#if: UbuntuHelp:Repositories/CommandLine|српски / srpski| [[::Repositories/CommandLine/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/sv | • {{#if: UbuntuHelp:Repositories/CommandLine|svenska| [[::Repositories/CommandLine/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/th | • {{#if: UbuntuHelp:Repositories/CommandLine|ไทย| [[::Repositories/CommandLine/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/tr | • {{#if: UbuntuHelp:Repositories/CommandLine|Türkçe| [[::Repositories/CommandLine/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/vi | • {{#if: UbuntuHelp:Repositories/CommandLine|Tiếng Việt| [[::Repositories/CommandLine/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/yue | • {{#if: UbuntuHelp:Repositories/CommandLine|粵語| [[::Repositories/CommandLine/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/zh | • {{#if: UbuntuHelp:Repositories/CommandLine|中文| [[::Repositories/CommandLine/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/zh-hans | • {{#if: UbuntuHelp:Repositories/CommandLine|中文(简体)| [[::Repositories/CommandLine/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Repositories/CommandLine | UbuntuHelp:Repositories/CommandLine | {{#if: | :}}Repositories/CommandLine}}/zh-hant | • {{#if: UbuntuHelp:Repositories/CommandLine|中文(繁體)| [[::Repositories/CommandLine/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:Repositories/CommandLine|:Repositories/CommandLine|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :Repositories/CommandLine/zh | | {{#ifexist: Repositories/CommandLine/zh | | {{#ifeq: {{#titleparts:Repositories/CommandLine|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:Repositories/CommandLine|1|-1|}} | zh | | }}
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. 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 Managing Repositories in Ubuntu or Kubuntu instead.
背景信息
Ubuntu 用apt 包进行管理. Apt在文件中存储了一系列知识注解或软件信道
/etc/apt/sources.list
在命令行编辑这些文件,我们可以添加, 移动, 活临时使软件的知识注解无效. 注意: 在编辑它们之前备份一个配置文件是一个好的编辑方式如 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.
- 在没有hashes的这一行是 apt的注解行. 首先两个 apt 行在我们的例子中如下
deb http://archive.ubuntu.com/ubuntu dapper main restricted deb-src http://archive.ubuntu.com/ubuntu dapper main restricted
- Here's what they say:
- 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
如果你只想要普通包而不是多元包,就从命令行中删除所有的含有'multiverse' 的命令行.只要你满意你自己的选择就将你修改后的文件保存。现在,用一下命令从新的添加注解中重置升级包:
sudo apt-get update
Done! 你的系统已经准备好安装领域和多元的注解包了。
Adding Commercial Repository
With Feisty (7.04) there is now a repository specially for commercial software. You can add it with following line in your /etc/apt/sources.list file:
deb http://archive.canonical.com/ubuntu feisty-commercial main
Then update as before:
sudo apt-get update
Be aware that the software contained within this repository is NOT open source.
Adding Other Repositories
Note: There are some (but not many) good reasons for which you might want to add non-Ubuntu repositories to your list of software sources. Some software cannot be distributed by Ubuntu due to patent and licensing restrictions in some countries (see the RestrictedFormats page for examples). You might want to add repositories that offer such software. Make sure that all repositories you add in this way have been tested and are known to work on Ubuntu systems. 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.
- You can add custom software repositories by adding the apt repository line of your software source to the list of repositories. It should look somehting like this:
deb http://mirror3.ubuntulinux.nl/ dapper-seveas freenx
- Add the line at the end of your sources.list and save the file.
- Next, make apt aware of the new software repositories by issuing the following command:
sudo apt-get update
- Done! The new software repositories should now be available for use.
Enabling Repositories with a (non-interactive) Script
This section is directed at advanced users.
Problem: You are looking for a way to enable the extra repositories without any user input.
Example: You are creating a custom install script for an application that needs software packages from the Universe or Multiverse repositories.
What follows is a simple script that enables the extra repositories that are commented out on a default install of Ubuntu 6.06 LTS.
- First, save your original sources.list file.
sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig
- Now make the changes to uncomment all respositories listed in the sources.list file.
sudo sed -i -e "s/# deb/deb/g" /etc/apt/sources.list
- Make apt aware of the new software repositories by issuing the following command:
sudo apt-get update
- Done! The new software repositories should now be available for use.
Suggestions & Recommendations
- It is always a good idea to back up configuration files like /etc/apt/sources.list before you begin editing. You can then revert your changes if needed. If things go badly wrong, head over to http://www.ubuntulinux.nl/source-o-matic and let the script create a new sources.list file for you.
- 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.
Further Reading
- The Debian Apt User Manual
- Apt-get
- Software Management
- Secure Apt on the Debian Wiki