特殊:Badtitle/NS100:Repositories/CommandLine
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/Repositories/CommandLine }} |
点击翻译: |
English {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/af | • {{#if: php5|Afrikaans| [[::Repositories/CommandLine/af|Afrikaans]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/ar | • {{#if: php5|العربية| [[::Repositories/CommandLine/ar|العربية]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/az | • {{#if: php5|azərbaycanca| [[::Repositories/CommandLine/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/bcc | • {{#if: php5|جهلسری بلوچی| [[::Repositories/CommandLine/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/bg | • {{#if: php5|български| [[::Repositories/CommandLine/bg|български]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/br | • {{#if: php5|brezhoneg| [[::Repositories/CommandLine/br|brezhoneg]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/ca | • {{#if: php5|català| [[::Repositories/CommandLine/ca|català]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/cs | • {{#if: php5|čeština| [[::Repositories/CommandLine/cs|čeština]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/de | • {{#if: php5|Deutsch| [[::Repositories/CommandLine/de|Deutsch]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/el | • {{#if: php5|Ελληνικά| [[::Repositories/CommandLine/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/es | • {{#if: php5|español| [[::Repositories/CommandLine/es|español]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/fa | • {{#if: php5|فارسی| [[::Repositories/CommandLine/fa|فارسی]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/fi | • {{#if: php5|suomi| [[::Repositories/CommandLine/fi|suomi]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/fr | • {{#if: php5|français| [[::Repositories/CommandLine/fr|français]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/gu | • {{#if: php5|ગુજરાતી| [[::Repositories/CommandLine/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/he | • {{#if: php5|עברית| [[::Repositories/CommandLine/he|עברית]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/hu | • {{#if: php5|magyar| [[::Repositories/CommandLine/hu|magyar]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/id | • {{#if: php5|Bahasa Indonesia| [[::Repositories/CommandLine/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/it | • {{#if: php5|italiano| [[::Repositories/CommandLine/it|italiano]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/ja | • {{#if: php5|日本語| [[::Repositories/CommandLine/ja|日本語]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/ko | • {{#if: php5|한국어| [[::Repositories/CommandLine/ko|한국어]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/ksh | • {{#if: php5|Ripoarisch| [[::Repositories/CommandLine/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/mr | • {{#if: php5|मराठी| [[::Repositories/CommandLine/mr|मराठी]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/ms | • {{#if: php5|Bahasa Melayu| [[::Repositories/CommandLine/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/nl | • {{#if: php5|Nederlands| [[::Repositories/CommandLine/nl|Nederlands]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/no | • {{#if: php5|norsk| [[::Repositories/CommandLine/no|norsk]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/oc | • {{#if: php5|occitan| [[::Repositories/CommandLine/oc|occitan]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/pl | • {{#if: php5|polski| [[::Repositories/CommandLine/pl|polski]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/pt | • {{#if: php5|português| [[::Repositories/CommandLine/pt|português]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/ro | • {{#if: php5|română| [[::Repositories/CommandLine/ro|română]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/ru | • {{#if: php5|русский| [[::Repositories/CommandLine/ru|русский]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/si | • {{#if: php5|සිංහල| [[::Repositories/CommandLine/si|සිංහල]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/sq | • {{#if: php5|shqip| [[::Repositories/CommandLine/sq|shqip]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/sr | • {{#if: php5|српски / srpski| [[::Repositories/CommandLine/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/sv | • {{#if: php5|svenska| [[::Repositories/CommandLine/sv|svenska]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/th | • {{#if: php5|ไทย| [[::Repositories/CommandLine/th|ไทย]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/tr | • {{#if: php5|Türkçe| [[::Repositories/CommandLine/tr|Türkçe]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/vi | • {{#if: php5|Tiếng Việt| [[::Repositories/CommandLine/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/yue | • {{#if: php5|粵語| [[::Repositories/CommandLine/yue|粵語]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/zh | • {{#if: php5|中文| [[::Repositories/CommandLine/zh|中文]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/zh-hans | • {{#if: php5|中文(简体)| [[::Repositories/CommandLine/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}Repositories/CommandLine}}/zh-hant | • {{#if: php5|中文(繁體)| [[::Repositories/CommandLine/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:php5|:Repositories/CommandLine|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :Repositories/CommandLine/zh | | {{#ifexist: Repositories/CommandLine/zh | | {{#ifeq: {{#titleparts:Repositories/CommandLine|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:Repositories/CommandLine|1|-1|}} | zh | | }}
attachment:IconsPage/terminal.png This page describes how to manage software UbuntuHelp: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.
attachment:IconsPage/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 Managing Repositories in Ubuntu or Kubuntu instead.
Background Information
Ubuntu uses apt for package management. Apt stores a list of repositories or software channels in the file
/etc/apt/sources.list
By editing this file from the command line, we can add, remove, or temporarily disable software repositories.
attachment:IconsPage/eyes.png Note: It's always a good idea to backup a configuration file like sources.list before you edit it. To do so, issue the following command:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
Typically, the contents of the /etc/apt/sources.list file may look something like this:
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
Explanation of the Repository Format
- All the lines beginning with one or two hashes (#) are comments and do not get read by apt or its front-ends apt-get, Synaptic, and Adept.
- The lines without hashes are apt repository lines. The first two apt lines in our example are
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: These repositories contain binaries or precompiled packages. These repositories are required for most users.
- deb-src: These repositories contain the source code of the packages. Useful for developers.
- http://archive.ubuntu.com/ubuntu: The URI (Uniform Resource Identifier), in this case a location on the internet. See the official mirror list or the self-maintained mirror list to find other mirrors.
- dapper is the release name or version of your distribution.
- main & restricted are the section names or what components. There can be several section names, separated by spaces.
Adding the Universe and Multiverse Repositories
Additional software repositories such as what Universe and Multiverse can be enabled by uncommenting the corresponding apt line (i.e. delete the '#' at the beginning of the line). In our example, we would uncomment the following lines:
deb http://archive.ubuntu.com/ubuntu dapper universe multiverse deb-src http://archive.ubuntu.com/ubuntu dapper universe multiverse
and, if security fixes and updates are enabled for Main and Restricted, we'd also add the following lines, to make sure we get upgrades for our Universe and Multiverse packages (not doing so may result in version mismatch when installing or upgrading packages):
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
attachment:IconsPage/eyes.png If you want to enable only Universe but not Multiverse, delete the word 'multiverse' from the lines.
Once you are satisfied with your choices, save the file. Now, retrieve the updated package lists from the newly added repositories by issuing the following command:
sudo apt-get update
Done! Your system is ready to install packages from the Universe and Multiverse repositories.
Adding Other Repositories
attachment:IconsPage/warning.png 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
attachment:IconsPage/eyes.png 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
- Secure Apt on the Debian Wiki